Class EmpiricalDistribution
- java.lang.Object
-
- dev.nm.stat.distribution.univariate.EmpiricalDistribution
-
- All Implemented Interfaces:
ProbabilityDistribution
- Direct Known Subclasses:
ADFAsymptoticDistribution
,ADFAsymptoticDistribution1
,ADFDistribution
,ADFFiniteSampleDistribution
,FisherExactDistribution
,JarqueBeraDistribution
,JohansenAsymptoticDistribution
public class EmpiricalDistribution extends Object implements ProbabilityDistribution
An empirical cumulative probability distribution function is a cumulative probability distribution function that assigns probability 1/n at each of the n numbers in a sample. The R equivalent function isecdf
.
-
-
Constructor Summary
Constructors Constructor Description EmpiricalDistribution(double[] data)
Construct an empirical distribution from a sample using the default quantile typeQuantile.QuantileType.APPROXIMATELY_MEDIAN_UNBIASED
.EmpiricalDistribution(double[] observations, Quantile.QuantileType quantileType)
Construct an empirical distribution from a sample.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description double
cdf(double x)
Gets the cumulative probability F(x) = Pr(X ≤ x).double
density(double x)
This is the probability mass function for the discrete sample.double
entropy()
Deprecated.Not supported yet.double
kurtosis()
Gets the excess kurtosis of this distribution.double
mean()
Gets the mean of this distribution.double
median()
Gets the median of this distribution.double
moment(double x)
Deprecated.Not supported yet.int
nSamples()
Get the number of samples in the empirical distribution.double
quantile(double u)
Gets the quantile, the inverse of the cumulative distribution function.double
skew()
Gets the skewness of this distribution.double[]
toArray()
Get the sorted sample.double
variance()
Gets the variance of this distribution.
-
-
-
Constructor Detail
-
EmpiricalDistribution
public EmpiricalDistribution(double[] observations, Quantile.QuantileType quantileType)
Construct an empirical distribution from a sample.- Parameters:
observations
- a samplequantileType
- specify how the quantile function is computed
-
EmpiricalDistribution
public EmpiricalDistribution(double[] data)
Construct an empirical distribution from a sample using the default quantile typeQuantile.QuantileType.APPROXIMATELY_MEDIAN_UNBIASED
.- Parameters:
data
- a sample
-
-
Method Detail
-
nSamples
public int nSamples()
Get the number of samples in the empirical distribution.- Returns:
- the number of samples
-
toArray
public double[] toArray()
Get the sorted sample.- Returns:
- the sorted sample
-
mean
public double mean()
Description copied from interface:ProbabilityDistribution
Gets the mean of this distribution.- Specified by:
mean
in interfaceProbabilityDistribution
- Returns:
- the mean
- See Also:
- Wikipedia: Expected value
-
median
public double median()
Description copied from interface:ProbabilityDistribution
Gets the median of this distribution.- Specified by:
median
in interfaceProbabilityDistribution
- Returns:
- the median
- See Also:
- Wikipedia: Median
-
variance
public double variance()
Description copied from interface:ProbabilityDistribution
Gets the variance of this distribution.- Specified by:
variance
in interfaceProbabilityDistribution
- Returns:
- the variance
- See Also:
- Wikipedia: Variance
-
skew
public double skew()
Description copied from interface:ProbabilityDistribution
Gets the skewness of this distribution.- Specified by:
skew
in interfaceProbabilityDistribution
- Returns:
- the skewness
- See Also:
- Wikipedia: Skewness
-
kurtosis
public double kurtosis()
Description copied from interface:ProbabilityDistribution
Gets the excess kurtosis of this distribution.- Specified by:
kurtosis
in interfaceProbabilityDistribution
- Returns:
- the excess kurtosis
- See Also:
- Wikipedia: Kurtosis
-
entropy
@Deprecated public double entropy()
Deprecated.Not supported yet.Description copied from interface:ProbabilityDistribution
Gets the entropy of this distribution.- Specified by:
entropy
in interfaceProbabilityDistribution
- Returns:
- the entropy
- See Also:
- Wikipedia: Entropy (information theory)
-
cdf
public double cdf(double x)
Description copied from interface:ProbabilityDistribution
Gets the cumulative probability F(x) = Pr(X ≤ x).- Specified by:
cdf
in interfaceProbabilityDistribution
- Parameters:
x
- x- Returns:
- F(x) = Pr(X ≤ x)
- See Also:
- Wikipedia: Cumulative distribution function
-
quantile
public double quantile(double u)
Gets the quantile, the inverse of the cumulative distribution function. It is the value below which random draws from the distribution would fall u×100 percent of the time.
This may not always exist. For an empirical distribution, this implementation assumes the following.F-1(u) = x, such that Pr(X ≤ x) = u
F-1(0) = the minimum x value F-1(1) = the maximum x value
- Specified by:
quantile
in interfaceProbabilityDistribution
- Parameters:
u
-u
, a quantile- Returns:
- F-1(u)
- See Also:
- Wikipedia: Quantile function
-
density
public double density(double x)
This is the probability mass function for the discrete sample.- Specified by:
density
in interfaceProbabilityDistribution
- Parameters:
x
- an observation- Returns:
pmf(x)
- See Also:
-
moment
@Deprecated public double moment(double x)
Deprecated.Not supported yet.Description copied from interface:ProbabilityDistribution
The moment generating function is the expected value of etX. That is,E(etX)
This may not always exist.- Specified by:
moment
in interfaceProbabilityDistribution
- Parameters:
x
- t- Returns:
- E(exp(tX))
- See Also:
- Wikipedia: Moment-generating function
-
-