Processing math: 63%
SciPy

This is documentation for an old release of SciPy (version 0.19.0). Search for this page in the documentation of the latest stable release (version 1.15.1).

Continuous Statistical Distributions

Overview

All distributions will have location (L) and Scale (S) parameters along with any shape parameters needed, the names for the shape parameters will vary. Standard form for the distributions will be given where L=0.0 and S=1.0. The nonstandard forms can be obtained for the various functions using (note U is a standard uniform random variate).

Function Name Standard Function Transformation
Cumulative Distribution Function (CDF) F(x) F(x;L,S)=F((xL)S)
Probability Density Function (PDF) f(x)=F(x) f(x;L,S)=1Sf((xL)S)
Percent Point Function (PPF) G(q)=F1(q) G(q;L,S)=L+SG(q)
Probability Sparsity Function (PSF) g(q)=G(q) g(q;L,S)=Sg(q)
Hazard Function (HF) ha(x)=f(x)1F(x) ha(x;L,S)=1Sha((xL)S)
Cumulative Hazard Function (CHF) Ha(x)= log11F(x) Ha(x;L,S)=Ha((xL)S)
Survival Function (SF) S(x)=1F(x) S(x;L,S)=S((xL)S)
Inverse Survival Function (ISF) Z(α)=S1(α)=G(1α) Z(α;L,S)=L+SZ(α)
Moment Generating Function (MGF) MY(t)=E[eYt] MX(t)=eLtMY(St)
Random Variates Y=G(U) X=L+SY
(Differential) Entropy h[Y]=f(y)logf(y)dy h[X]=h[Y]+logS
(Non-central) Moments μn=E[Yn] E[Xn]=LnNk=0(nk)(SL)kμk
Central Moments μn=E[(Yμ)n] E[(XμX)n]=Snμn
mean (mode, median), var μ,μ2 L+Sμ,S2μ2
skewness, kurtosis γ1=μ3(μ2)3/2, γ2=μ4(μ2)23 γ1,γ2

Moments

Non-central moments are defined using the PDF

μn=xnf(x)dx.

Note, that these can always be computed using the PPF. Substitute x=G(q) in the above equation and get

μn=10Gn(q)dq

which may be easier to compute numerically. Note that q=F(x) so that dq=f(x)dx. Central moments are computed similarly μ=μ1

μn=(xμ)nf(x)dx=10(G(q)μ)ndq=nk=0(nk)(μ)kμnk

In particular

μ3=μ33μμ2+2μ3=μ33μμ2μ3μ4=μ44μμ3+6μ2μ23μ4=μ44μμ36μ2μ2μ4

Skewness is defined as

γ1=β1=μ3μ3/22

while (Fisher) kurtosis is

γ2=μ4μ223,

so that a normal distribution has a kurtosis of zero.

Median and mode

The median, mn is defined as the point at which half of the density is on one side and half on the other. In other words, F(mn)=12 so that

mn=G(12).

In addition, the mode, md , is defined as the value for which the probability density function reaches it’s peak

md=argmax

Fitting data

To fit data to a distribution, maximizing the likelihood function is common. Alternatively, some distributions have well-known minimum variance unbiased estimators. These will be chosen by default, but the likelihood function will always be available for minimizing.

If f\left(x;\boldsymbol{\theta}\right) is the PDF of a random-variable where \boldsymbol{\theta} is a vector of parameters ( e.g. L and S ), then for a collection of N independent samples from this distribution, the joint distribution the random vector \mathbf{x} is

f\left(\mathbf{x};\boldsymbol{\theta}\right)=\prod_{i=1}^{N}f\left(x_{i};\boldsymbol{\theta}\right).

The maximum likelihood estimate of the parameters \boldsymbol{\theta} are the parameters which maximize this function with \mathbf{x} fixed and given by the data:

\begin{eqnarray*} \boldsymbol{\theta}_{es} & = & \arg\max_{\boldsymbol{\theta}}f\left(\mathbf{x};\boldsymbol{\theta}\right)\\ & = & \arg\min_{\boldsymbol{\theta}}l_{\mathbf{x}}\left(\boldsymbol{\theta}\right).\end{eqnarray*}

Where

\begin{eqnarray*} l_{\mathbf{x}}\left(\boldsymbol{\theta}\right) & = & -\sum_{i=1}^{N}\log f\left(x_{i};\boldsymbol{\theta}\right)\\ & = & -N\overline{\log f\left(x_{i};\boldsymbol{\theta}\right)}\end{eqnarray*}

Note that if \boldsymbol{\theta} includes only shape parameters, the location and scale-parameters can be fit by replacing x_{i} with \left(x_{i}-L\right)/S in the log-likelihood function adding N\log S and minimizing, thus

\begin{eqnarray*} l_{\mathbf{x}}\left(L,S;\boldsymbol{\theta}\right) & = & N\log S-\sum_{i=1}^{N}\log f\left(\frac{x_{i}-L}{S};\boldsymbol{\theta}\right)\\ & = & N\log S+l_{\frac{\mathbf{x}-S}{L}}\left(\boldsymbol{\theta}\right)\end{eqnarray*}

If desired, sample estimates for L and S (not necessarily maximum likelihood estimates) can be obtained from samples estimates of the mean and variance using

\begin{eqnarray*} \hat{S} & = & \sqrt{\frac{\hat{\mu}_{2}}{\mu_{2}}}\\ \hat{L} & = & \hat{\mu}-\hat{S}\mu\end{eqnarray*}

where \mu and \mu_{2} are assumed known as the mean and variance of the untransformed distribution (when L=0 and S=1 ) and

\begin{eqnarray*} \hat{\mu} & = & \frac{1}{N}\sum_{i=1}^{N}x_{i}=\bar{\mathbf{x}}\\ \hat{\mu}_{2} & = & \frac{1}{N-1}\sum_{i=1}^{N}\left(x_{i}-\hat{\mu}\right)^{2}=\frac{N}{N-1}\overline{\left(\mathbf{x}-\bar{\mathbf{x}}\right)^{2}}\end{eqnarray*}

Standard notation for mean

We will use

\overline{y\left(\mathbf{x}\right)}=\frac{1}{N}\sum_{i=1}^{N}y\left(x_{i}\right)

where N should be clear from context as the number of samples x_{i}

References

Continuous Distributions in scipy.stats