Statistical Distributions
numerics4net provides the means to compute the cumulative distribution function (CDF) probabilities for common distributions. Along with CDF computations, numerics4net provides for the evaluation of inverse CDF values. Additionally, numerics4net provided the means to compute the probability mass function (PMF) probabilities for discrete deistributions.
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 numerics4net:
Distribution | Class | Parameters |
---|---|---|
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 - pFor 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