Class BinomialDistribution
- java.lang.Object
-
- dev.nm.stat.distribution.univariate.BinomialDistribution
-
- All Implemented Interfaces:
ProbabilityDistribution
public class BinomialDistribution extends Object implements ProbabilityDistribution
The binomial distribution is the discrete probability distribution of the number of successes in a sequence of n independent yes/no experiments, each of which yields success with probability p. The binomial distribution is frequently used to model the number of successes in a sample of size n drawn with replacement from a population of size N. For N much larger than n, the binomial distribution is a good approximation of hypergeometric distribution.- See Also:
- Wikipedia: Binomial distribution
-
-
Constructor Summary
Constructors Constructor Description BinomialDistribution(int n, double p)Construct a Binomial distribution.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublecdf(double x)Gets the cumulative probability F(x) = Pr(X ≤ x).doubledensity(double x)This is the probability mass function.doubleentropy()Gets the entropy of this distribution.doublekurtosis()Gets the excess kurtosis of this distribution.doublemean()Gets the mean of this distribution.doublemedian()Gets the median of this distribution.doublemoment(double t)The moment generating function is the expected value of etX.doublequantile(double u)Gets the quantile, the inverse of the cumulative distribution function.doubleskew()Gets the skewness of this distribution.doublevariance()Gets the variance of this distribution.
-
-
-
Method Detail
-
mean
public double mean()
Description copied from interface:ProbabilityDistributionGets the mean of this distribution.- Specified by:
meanin interfaceProbabilityDistribution- Returns:
- the mean
- See Also:
- Wikipedia: Expected value
-
median
public double median()
Gets the median of this distribution. The result is rounded rounded down to an integer.- Specified by:
medianin interfaceProbabilityDistribution- Returns:
- median
- See Also:
- Wikipedia: Median
-
variance
public double variance()
Description copied from interface:ProbabilityDistributionGets the variance of this distribution.- Specified by:
variancein interfaceProbabilityDistribution- Returns:
- the variance
- See Also:
- Wikipedia: Variance
-
skew
public double skew()
Description copied from interface:ProbabilityDistributionGets the skewness of this distribution.- Specified by:
skewin interfaceProbabilityDistribution- Returns:
- the skewness
- See Also:
- Wikipedia: Skewness
-
kurtosis
public double kurtosis()
Description copied from interface:ProbabilityDistributionGets the excess kurtosis of this distribution.- Specified by:
kurtosisin interfaceProbabilityDistribution- Returns:
- the excess kurtosis
- See Also:
- Wikipedia: Kurtosis
-
cdf
public double cdf(double x)
Gets the cumulative probability F(x) = Pr(X ≤ x).- Specified by:
cdfin interfaceProbabilityDistribution- Parameters:
x- the number of success trials, an integer; rounded down to the closest integer if x is not an integer- Returns:
- cdf(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. Uses the Cornish-Fisher Expansion to include a skewness correction to a normal approximation. This gives an initial value which never seems to be off by more than 1 or 2. A search is then conducted of values close to this initial start point.F-1(u) = x, such that Pr(X ≤ x) = u
- Specified by:
quantilein interfaceProbabilityDistribution- Parameters:
u- a quantile- Returns:
qbinom(u)- See Also:
- qbinom
-
density
public double density(double x)
This is the probability mass function.- Specified by:
densityin interfaceProbabilityDistribution- Parameters:
x- the number of success trials, an integer; rounded down to the closest integer if x is not an integer- Returns:
pmf(x)- See Also:
-
entropy
public double entropy()
Description copied from interface:ProbabilityDistributionGets the entropy of this distribution.- Specified by:
entropyin interfaceProbabilityDistribution- Returns:
- the entropy
- See Also:
- Wikipedia: Entropy (information theory)
-
moment
public double moment(double t)
Description copied from interface:ProbabilityDistributionThe moment generating function is the expected value of etX. That is,E(etX)
This may not always exist.- Specified by:
momentin interfaceProbabilityDistribution- Parameters:
t- t- Returns:
- E(exp(tX))
- See Also:
- Wikipedia: Moment-generating function
-
-