# dstats.distrib

Probability distribution CDFs, PDFs/PMFs, and a few inverse CDFs.

## Members

### Functions

betaCDF
double betaCDF(double x, double alpha, double beta)
betaCDFR
double betaCDFR(double x, double alpha, double beta)
betaPDF
double betaPDF(double x, double alpha, double beta)
binomialCDF
double binomialCDF(ulong k, ulong n, double p)

P(K <= k) where K is random variable.

binomialCDFR
double binomialCDFR(ulong k, ulong n, double p)

P(K >= k) where K is random variable.

binomialPMF
double binomialPMF(ulong k, ulong n, double p)
cauchyCDF
double cauchyCDF(double X, double X0 = 0, double gamma = 1)
cauchyCDFR
double cauchyCDFR(double X, double X0 = 0, double gamma = 1)
cauchyPDF
double cauchyPDF(double X, double X0 = 0, double gamma = 1)
chiSquareCDF
double chiSquareCDF(double x, double v)

&chi;2 distribution function and its complement.

chiSquareCDFR
double chiSquareCDFR(double x, double v)
chiSquarePDF
double chiSquarePDF(double x, double v)
dirichletPDF
double dirichletPDF(X x, A alpha)

The Dirichlet probability density.

exponentialCDF
double exponentialCDF(double x, double lambda)
exponentialCDFR
double exponentialCDFR(double x, double lambda)
exponentialPDF
double exponentialPDF(double x, double lambda)
fisherCDF
double fisherCDF(double x, double df1, double df2)
fisherCDFR
double fisherCDFR(double x, double df1, double df2)

The Fisher distribution, its complement, and inverse.

gammaCDF
double gammaCDF(double x, double rate, double shape)
gammaCDFR
double gammaCDFR(double x, double rate, double shape)
gammaPDF
double gammaPDF(double x, double rate, double shape)
hypergeometricCDF
double hypergeometricCDF(long x, long n1, long n2, long n)

P(X <= x), where X is random variable. Uses either direct summation, normal or binomial approximation depending on parameters.

hypergeometricCDFR
double hypergeometricCDFR(ulong x, ulong n1, ulong n2, ulong n)

P(X >= x), where X is random variable.

hypergeometricPMF
double hypergeometricPMF(long x, long n1, long n2, long n)
invBetaCDF
double invBetaCDF(double p, double alpha, double beta)
invBinomialCDF
uint invBinomialCDF(double pVal, uint n, double p)

Returns the value of k for the given p-value, n and p. If p-value does not exactly map to a value of k, the value for which binomialCDF(k, n, p) is closest to pVal is used.

invCauchyCDF
double invCauchyCDF(double p, double X0 = 0, double gamma = 1)
invChiSquareCDFR
double invChiSquareCDFR(double v, double p)

Inverse of complemented &chi;2 distribution

invExponentialCDF
double invExponentialCDF(double p, double lambda)
invFisherCDFR
double invFisherCDFR(double df1, double df2, double p)

Inverse of complemented Fisher distribution

invGammaCDF
double invGammaCDF(double p, double rate, double shape)

This just calls invGammaCDFR w/ 1 - p b/c invGammaCDFR is more accurate, but this function is necessary for consistency.

invGammaCDFR
double invGammaCDFR(double p, double rate, double shape)
invLaplaceCDF
double invLaplaceCDF(double p, double mu = 0, double b = 1)
invNegBinomCDF
ulong invNegBinomCDF(double pVal, ulong n, double p)
invNormalCDF
double invNormalCDF(double p, double mean = 0, double sd = 1)

Inverse of Normal distribution function

invPoissonCDF
uint invPoissonCDF(double pVal, double lambda)

Returns the value of k for the given p-value and lambda. If p-val doesn't exactly map to a value of k, the k for which poissonCDF(k, lambda) is closest to pVal is used.

invStudentsTCDF
double invStudentsTCDF(double p, double df)

Inverse of Student's t distribution * Given probability p and degrees of freedom df, finds the argument t such that the one-sided studentsDistribution(nu,t) is equal to p. Used to test whether two distributions have the same standard deviation. *

kolmogorovDistrib
double kolmogorovDistrib(immutable double x)

Kolmogorov distribution. Used in Kolmogorov-Smirnov testing.

laplaceCDF
double laplaceCDF(double X, double mu = 0, double b = 1)
laplaceCDFR
double laplaceCDFR(double X, double mu = 0, double b = 1)
laplacePDF
double laplacePDF(double x, double mu = 0, double b = 1)
logNormalCDF
double logNormalCDF(double x, double mu = 0, double sigma = 1)
logNormalCDFR
double logNormalCDFR(double x, double mu = 0, double sigma = 1)
logNormalPDF
double logNormalPDF(double x, double mu = 0, double sigma = 1)
negBinomCDF
double negBinomCDF(ulong k, ulong n, double p)

Negative binomial distribution.

negBinomCDFR
double negBinomCDFR(ulong k, ulong n, double p)

Probability that k or more failures precede the nth success.

negBinomPMF
double negBinomPMF(ulong k, ulong n, double p)
normalCDF
double normalCDF(double x, double mean = 0, double stdev = 1)

P(X < x) for normal distribution where X is random var.

normalCDFR
double normalCDFR(double x, double mean = 0, double stdev = 1)

P(X > x) for normal distribution where X is random var.

normalPDF
double normalPDF(double x, double mean = 0, double sd = 1)
paramFunctor
ParamFunctor!(distrib) paramFunctor(ParameterTypeTuple!(distrib)[1..\$] parameters)

Takes a distribution function (CDF or PDF/PMF) as a template argument, and parameters as function arguments in the order that they appear in the function declaration and returns a functor that binds the supplied parameters to the distribution function. Assumes the non-parameter argument is the first argument to the distribution function.

parametrize
double delegate(ParameterTypeTuple!(distrib)) parametrize(ParameterTypeTuple!(distrib)[1..\$] parameters)

Takes a distribution function (CDF or PDF/PMF) as a template argument, and parameters as function arguments in the order that they appear in the function declaration and returns a delegate that binds the supplied parameters to the distribution function. Assumes the non-parameter argument is the first argument to the distribution function.

poissonCDF
double poissonCDF(ulong k, double lambda)

P(K <= k) where K is r.v.

poissonCDFR
double poissonCDFR(ulong k, double lambda)

P(K >= k) where K is r.v.

poissonPMF
double poissonPMF(ulong k, double lambda)
studentsTCDF
double studentsTCDF(double t, double df)
studentsTCDFR
double studentsTCDFR(double t, double df)
studentsTPDF
double studentsTPDF(double t, double df)
uniformCDF
double uniformCDF(double X, double lower, double upper)
uniformCDFR
double uniformCDFR(double X, double lower, double upper)
uniformPDF
double uniformPDF(double X, double lower, double upper)
weibullCDF
double weibullCDF(double x, double shape, double scale = 1)
weibullCDFR
double weibullCDFR(double x, double shape, double scale = 1)
weibullPDF
double weibullPDF(double x, double shape, double scale = 1)

### Structs

ParamFunctor
struct ParamFunctor(alias distrib)

## Meta

### Authors

David Simcha, Don Clugston