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 double
cdf(double x)
Gets the cumulative probability F(x) = Pr(X ≤ x).double
density(double x)
This is the probability mass function.double
entropy()
Gets the entropy of this distribution.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 t)
The moment generating function is the expected value of etX.double
quantile(double u)
Gets the quantile, the inverse of the cumulative distribution function.double
skew()
Gets the skewness of this distribution.double
variance()
Gets the variance of this distribution.
-
-
-
Method Detail
-
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()
Gets the median of this distribution. The result is rounded rounded down to an integer.- Specified by:
median
in interfaceProbabilityDistribution
- Returns:
- 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
-
cdf
public double cdf(double x)
Gets the cumulative probability F(x) = Pr(X ≤ x).- Specified by:
cdf
in 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:
quantile
in 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:
density
in 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:ProbabilityDistribution
Gets the entropy of this distribution.- Specified by:
entropy
in interfaceProbabilityDistribution
- Returns:
- the entropy
- See Also:
- Wikipedia: Entropy (information theory)
-
moment
public double moment(double t)
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:
t
- t- Returns:
- E(exp(tX))
- See Also:
- Wikipedia: Moment-generating function
-
-