Statistical Distributions

numerics4j provides the means to compute the cumulative distribution function (CDF) probabilities for common distributions. Along with CDF computations, numerics4j provides for the evaluation of inverse CDF values. Additionally, numerics4j provided the means to compute the probability mass function (PMF) probabilities for discrete distributions.

To use a distribution, simply create a new distribution object with the desired parameters. With the distribution object, call the cumulativeProbability method to compute CDF probabilities, the inverseCumulativeProbability method to compute inverse CDF values and, the probability method to compute PMF probabilities:

// create a distribution with the desired parameters
NormalDistribution z = new NormalDistribution(0.0, 1.0);

double p = z.cumulativeProbability(1.96);         // p = P(z <= 1.96)
double x = z.inverseCumulativeProbability(0.975); // P(z <= x) = 0.975

// create a discrete distribution
BinomialDistribution b = new BinomialDistribution(10, 0.5);
p = b.probability(4); // p = P(b = 4)

The following distribution are supplied by numerics4j:

DistributionClassParameters
Beta BetaDistribution
alpha
beta
Binomial BinomialDistribution
number of trials
probability of success
Cauchy CauchyDistribution
location
scale
Chi-Squared ChiSquaredDistribution degrees of freedom
Exponential ExponentialDistribution mean
F FDistribution
numerator degrees of freedom
denominator degrees of freedom
Gamma GammaDistribution
alpha
beta
Geometric GeometricDistribution probability of success
Hypergeometric HypergeometricDistribution
number of success in population
number of failures in population
sample size
Laplace LaplaceDistribution
mean
scale
Logistic LogisticDistribution
mean
scale
Log Normal LogNormalDistribution
mean
standard deviation
Negative Binomial NegativeBinomialDistribution
number of successes
probability of success
Normal NormalDistribution
mean
standard deviation
Poisson PoissonDistribution mean
Rayleigh RayleighDistribution scale
t TDistribution degrees of freedom
Uniform UniformDistribution
lower bound
upper bound

Inverse CDF's for Discrete Distributions

Special care is given to computing the inverse CDF for discrete distributions. This is because of the inexactness of the mapping from cumulative probabilities to quantiles. As such, the return value, x, of the inverseCumulativeProbability method satifies the following to criteria:

For the distribution X and target probability p:
x is the largest integer such that P(X <= x) <= p and
x is the smallest integer such that P(X >= x) >= 1 - p
For example, for a Binomial(10, 0.375) distribution:
BinomialDistribution b = new BinomialDistribution(10, 0.375);
double p = 0.75;
double x = b.inverseCumulativeProbability(p);
// assert: b.cumulativeProbability(x) <= 0.75
// assert: b.cumulativeProbability(x + 1) >= 0.75
// assert: 1.0 - b.cumulativeProbability(x) >= 0.25
// assert: 1.0 - b.cumulativeProbability(x + 1) <= 0.25