5.1. Probability Background

Objectives: Statement and limited explanation of important probability concepts that underlie aggregate calculations.

Audience: Readers looking for a probability refresher.

Prerequisites: Knowledge of basic probability and calculus (real analysis).

See also: Insurance Probability.

Notation: The variance of a random variable \(X\) is \(\mathsf{var}(X)=\mathsf{E}[X^2]-\mathsf{E}[X]^2\). The standard deviation is \(\sigma(X)=\sqrt{\mathsf{var}(X)}\). The coefficient of variation (CV) of \(X\) is \(\mathsf{CV}(X)=\sigma(X)/\mathsf{E}[X]\). The skewness of \(X\) is \(\mathsf{E}[(X-\mathsf{E}[X])^3]/\sigma(X)^3\).

Contents:

5.1.1. Helpful References

5.1.2. Types

Todo

Documentation to follow.

5.1.3. Severity Distributions

5.1.3.1. Computing moments

Higher moments of a layer with a limit \(y\) excess of an attachment (deductible, retention) \(a\) can be computed as

\[\begin{split}\mathsf E[((X-a)^+ \wedge l)^n] &= \int_a^{a+l} (x-a)^n f(x)\,dx + l^nS(a+l) \\ &= \sum_{k=0}^n (-1)^k \binom{n}{k} a^{n-k} \int_a^{a+l} x^k f(x)\,dx + l^nS(a+l) \\ &= \sum_{k=0}^n (-1)^k \binom{n}{k} a^{n-k} \left(\mathsf E[k; a+l] - \mathsf E[k; a]\right)+ l^nS(a+l)\end{split}\]

where

\[\mathsf E[k; a] = \int_0^a x^kf(x)\,dx\]

is the partial expectation function.

5.1.3.1.1. Lognormal

For the lognormal, the trick for higher moments is to observe that if \(X\) is lognormal \((\mu,\sigma)\) then \(X^k\) is lognormal \((k\mu, k\sigma)\). The formula for partial expectations of the lognormal is easy to compute by substitution, giving

\[\mathsf E[k, a] = \exp(k\mu + k^2\sigma^2/2)\Phi\left( \frac{\log x -\mu - k\sigma^2}{\sigma} \right)\]

5.1.3.1.2. Densities of the form \(f(x)=x^\alpha c(\alpha)g(x)\)

\[\begin{split}\mathsf E[k, a] &= \int_0^a x^k x^\alpha c(\alpha)g(x) \,dx \\ &= \frac{c(\alpha)}{c(n+\alpha)}\int_0^a x^{k+\alpha} c(k+\alpha)g(x) \,dx \\ &= \frac{c(\alpha)}{c(n+\alpha)}F_{k+\alpha}(a)\end{split}\]

are easy to express in terms of the distribution function. This is a broad class including the gamma.

5.1.3.1.3. Pareto

An easy integral computation, substitute \(y=\lambda + x\) to express in powers of \(y\):

\[\begin{split}\mathsf E[k, a] &= \int_0^a \alpha x^k \frac{\lambda^\alpha}{(\lambda + x)^{\alpha+1}}\,dx \\ &= \int_\lambda^{\lambda + a} \alpha\lambda^\alpha \frac{(y-\lambda)^k}{y^{\alpha+1}}\,dy \\ &= \sum_{i=0}^k (-1)^{k-i} \alpha\lambda^\alpha \binom{k}{i} \int_\lambda^{\lambda + a} y^{i-\alpha-1} \lambda^{k-i}\,dy \\ &= \sum_{i=0}^k (-1)^{k-i} \alpha\lambda^{\alpha+k-i} \binom{k}{i} \frac{y^{i-\alpha}}{i-\alpha}\big|_\lambda^{\lambda + a}.\end{split}\]

5.1.3.2. scipy.stats Severity Distributions

All zero, one, and two shape parameter scipy.stats continuous random variable classes can be used as severity distributions. See Appendix: scipy.stats Continuous Random Variables for details about each available option.

5.1.4. Frequency Distributions

The following reference is from the scipy documentation.

5.1.4.1. Bernoulli Distribution

The probability mass function for bernoulli is:

\[\begin{split}f(k) = \begin{cases}1-p &\text{if } k = 0\\ p &\text{if } k = 1\end{cases}\end{split}\]

for \(k\) in \(\{0, 1\}\), \(0 \leq p \leq 1\) bernoulli takes \(p\) as shape parameter, where \(p\) is the probability of a single success and \(1-p\) is the probability of a single failure.

5.1.4.2. Binomial Distribution

The probability mass function for binom is:

\[f(k) = \binom{n}{k} p^k (1-p)^{n-k}\]

for \(k \in \{0, 1, \dots, n\}\), \(0 \leq p \leq 1\) binom takes \(n\) and \(p\) as shape parameters, where \(p\) is the probability of a single success and \(1-p\) is the probability of a single failure.

5.1.4.3. Geometric Distribution

The probability mass function for geom is:

\[f(k) = (1-p)^{k-1} p\]

for \(k \ge 1\), \(0 < p \leq 1\) geom takes \(p\) as shape parameter, where \(p\) is the probability of a single success and \(1-p\) is the probability of a single failure.

5.1.4.4. Poisson Distribution

The probability mass function for poisson is:

\[f(k) = \exp(-\mu) \frac{\mu^k}{k!}\]

for \(k \ge 0\). poisson takes \(\mu \geq 0\) as shape parameter.

5.1.4.5. Neyman (A) Distribution

The Neyman distribution is a Poisson stopped-sum distribution of Poisson variables, see Johnson et al. [2005].

5.1.4.6. Fixed Distribution

The fixed distribution takes a single value with probability one.

5.1.5. Moment Generating Functions

The moment generating function of a random variable \(X\) is defined as

\[M_X(z)=\mathsf{E}[\exp(z X)].\]

The moment generating function is related to the characteristic function of \(X\) which is defined as \(\phi_X(z)=\mathsf{E}[\exp(iz X)]=M_X(iz)\). \(\phi\) is guaranteed to converge for all real \(z\) and so is preferred in certain situations.

Moment generating functions get their name from the fundamental property that

\[\frac{\partial^n M_X}{\partial z^n}\Big\vert_{z=0}=\mathsf{E}[X^n]\]

for all positive integers \(n\) provided the differential exists.

Let \(F\) be the distribution function of \(X\). Feller [1971] Section XVII.2a shows that if \(F\) has expectation \(\mu\) then \(\phi\), the characteristic function of \(F\), has a derivative \(\phi'\) and \(\phi'(0)=i\mu\). However the converse is false. Pitman proved that the following are equivalent.

  1. \(\phi'(0)=i\mu\).

  2. As \(t\to\infty\), \(t(1-F(t)+F(-t))\to 0\) and

    \[\label{feller1} \int_t^{-t} xdF(x) \to \mu,\]

    where \(F(-t):=\lim F(s)\) as \(s\uparrow t\).

  3. The average \((X_1+\cdots+X_n)/n\) tends in probability to \(\mu\), that is \(\mathsf{Pr}(| (X_1+\cdots +X_n)/n-\mu|>\epsilon)\to 0\) as \(n\to\infty\).

The condition for the limit in 2 to exist is weaker than the requirement that \(\mathsf{E}[X]\) exists if \(X\) is supported on the whole real line. For the expectation to exist requires \(\int_{-\infty}^{\infty} xdF(x)\) exists which means \(\lim_{t\to-\infty}\lim_{s\to\infty}\int_t^s xdF(x)\).

The moment generating function of a bivariate distribution \((X_1,X_2)\) is defined as

\[M_{X_1,X_2}(z_1,z_2)=\mathsf{E}[\exp(z_1 X_1+z_2 X_2)].\]

It has the property that

\[\frac{\partial^{m+n} M_{X_1,X_2}}{\partial z_1^m\partial z_2^n}\Big\vert_{(0,0)} =\mathsf{E}[X_1^mX_2^n]\]

for all positive integers \(n,m\).

The MGF of a normal variable with mean \(\mu\) and standard deviation \(\sigma\) is

\[M(z)=\exp(\mu z\sigma^2 z^2/2).\]

The MGF of a Poisson variable with mean \(n\) is

\[M(z)=\exp(n(e^{z}-1)).\]

See any standard text on probability for more information on moment generating functions, characteristic functions and modes of convergence.

5.1.6. Mixed Frequency Distributions

A random variable \(N\) is \(G\)-mixed Poisson if \(N\mid G\) has a Poisson \(nG\) distribution for some fixed non-negative \(n\) and a non-negative mixing distribution \(G\) with \(\mathsf E[G]=1\). Let \(\mathsf{var}(G)=c\) and let \(\mathsf E[G^3]=g\). Glenn Meyers calls \(c\) the contagion.

The MGF of a \(G\)-mixed Poisson is

\[\label{mgfi} M_N(z)=\mathsf E[e^{z N}]=\mathsf E[\mathsf E[e^{z N} \mid G]]=\mathsf E[e^{n G(e^z-1]})=M_G(n(e^z-1))\]

since \(M_G(z):=\mathsf E[e^{z G}]\) and the MGF of a Poisson with mean \(n\) is \(\exp(n(e^z-1))\). Thus

\[\mathsf E[N]=M_N'(0)=n M_G'(0)=n,\]

because \(\mathsf E[G]=M_G'(0)=1\). Similarly

\[\mathsf E[N^2]=M_N''(0)=n^2M_G''(0)+n M_G'(0)=n^2(1+c)+n\]

and so

\[\mathsf{var}(N)=n(1+cn).\]

Finally

\[\begin{split}\mathsf E[N^3] &= M_N'''(0) \\ &=n^3M_G'''(0)+3n^2M_G''(0)+n M_G'(0) = gn^3 + 3n^2(1+c) + n\end{split}\]

and therefore the central moment

\[\mathsf E(N-\mathsf E[N])^3 = n^3(g -3c -1) + 3cn^2 + n.\]

We can also assume \(G\) has mean \(n\) and work directly with \(G\) rather than \(nG\), \(\mathsf E[G]=1\). We will call both forms mixing distributions.

5.1.6.1. Gamma Mixing

A negative binomial is a gamma-mixed Poisson: if \(N \mid G\) is distributed as a Poisson with mean \(G\), and \(G\) has a gamma distribution, then the unconditional distribution of \(N\) is a negative binomial. A gamma distribution has a shape parameter \(a\) and a scale parameter \(\theta\) so that the density is proportional to \(x^{a-1}e^{x/\theta}\), \(\mathsf E[G]=a\theta\) and \(\mathsf{var}(G)=a\theta^2\).

Let \(c=\mathsf{var}(G)=\nu^2\), so \(\nu\) is the coefficient of variation of the mixing distribution. Then

  • \(a\theta=1\) and \(a\theta^2=c\)

  • \(\theta=c=\nu^2\), \(a=1/c\)

The non-central moments of the gamma distribution are \(\mathsf E[G^r]=\theta^r\Gamma(a+r)/\Gamma(a)\). Therefore \(Var(G) = a\theta^2\) and \(E(G-E(G))^3 = 2a\theta^3\). The skewness of \(G\) is \(\gamma = 2/\sqrt(a) = 2\nu\).

Applying the general formula for the third central moment of \(N\) we get an expression for the skewness

\[\mathsf{skew}(N) = \frac{n^3(\gamma -3c -1) + n^2(3c+2) + n}{(n(1+cn))^{3/2}}.\]

The corresponding MGF of the gamma is \(M_G(z) = (1-\theta z)^{-a}\).

The gamma and negative binomial occur in the literature with many different parameterizations. The main ones are shown in the next three tables.

Parameterizations of the Gamma Distribution

Model

Density

MGF

Mean

Var

  1. \(\alpha\), \(\beta\)

\(\frac{\textstyle x^{\alpha-1}e^{-x/\beta}}{\textstyle\beta^{\alpha}\Gamma(\alpha)}\)

\((1-\beta t)^{-\alpha}\)

\(\alpha\beta\)

\(\alpha\beta^2\)

  1. \(\alpha\), \(\beta\)

\(\frac{\textstyle x^{\alpha-1}\beta^{\alpha}e^{-x\beta}}{\textstyle\Gamma(\alpha)}\)

\((1-t/\beta)^{-\alpha}\)

\(\alpha/\beta\)

\(\alpha/\beta^2\)

  1. \(\alpha\), \(\theta\)

\(\frac{\textstyle x^{\alpha-1}e^{-x/\theta}}{\textstyle \theta^{\alpha}\Gamma(\alpha)}\)

\((1-t\theta)^{-\alpha}\)

\(\alpha\theta\)

\(\alpha\theta^2\)

Model (a) is used by Microsoft Excel, Wang [1998], and Johnson et al. [2005] Chapter 17. Model (b) is used by Bowers et al. [1997]. Model (c) is used by . Obviously model (c) is just model (a) with a change of notation.

Parameterizations of the Negative Binomial Distribution

Model

Density

MGF

Mean

Var

  1. \(\alpha\), \(\beta\)

\(\binom{\textstyle\alpha+x-1}{\textstyle x} \left(\frac{\textstyle \beta}{\textstyle 1+\beta}\right)^x \left(\frac{\textstyle 1}{\textstyle 1+\beta}\right)^{\alpha}\)

\((1-\beta(e^t-1))^{-\alpha}\)

\(\alpha\beta\)

\(\alpha\beta^2\)

  1. \(P\), \(k\)

\(\binom{\textstyle k+x-1}{\textstyle x} \left(\frac{\textstyle P}{\textstyle Q}\right)^x \left(\frac{\textstyle Q-P}{\textstyle Q}\right)^k\)

\((Q-Pe^t)^{-k}\)

\(kP\)

\(kPQ\)

  1. \(p\), \(r>0\)

\(\textstyle\binom{\textstyle r+x-1}{\textstyle x} p^rq^x\)

\(\frac{\textstyle p^r}{\textstyle (1-qe^s)^r}\)

\(rq/p\)

\(rq/p^2\)

Note that \(Q=P+1\), \(q=1-p\), \(0<p<1\) and \(r>0\), and \(P=1/(\beta+1)\).

Fitting the Negative Binomial Distribution

Model

Parameters

VM Scale

VM Shape

Ctg Scale

Ctg Shape

\(r\), \(\beta\)

\(r=m/(v-1)\)

\(\beta=v-1\)

\(r=1/c\)

\(\beta=cn\)

\(k\), \(P\)

\(k=m/(v-1)\)

\(P=v-1\)

\(k=1/c\)

\(P=cn\)

\(r\), \(p\)

\(r=m/(v-1)\)

\(p=1/v\)

\(r=1/c\)

\(p=1/(1+cn)\)

In model (c) the parameter \(r\) need not be an integer because the binomial coefficient can be computed as

\[\binom{r+x-1}{x}=\frac{\Gamma(r+x)}{\Gamma(r)x!},\]

an expression which is valid for all \(r\). The cumulative distribution function of the negative binomial can be computed using the cumulative distribution of the beta distribution. Using the model (c) parameterization, if \(N\) is negative binomial \(p,r\) then

\[\begin{split}\mathsf{Pr}(N\le k) &= \text{BETADIST}(p;r,k+1) \\ &:=\frac{1}{B(r,k+1)}\int_0^p u^{r-1} (1-u)^{k} du\end{split}\]

where \(B\) is the complete beta function. See Johnson, Kotz and Kemp [Eqn. 5.31] for a derivation. BETADIST is the Excel beta cumulative distribution function.

The name negative binomial comes from an analogy with the binomial. A binomial variable has parameters \(n\) and \(p\), mean \(np\) and variance \(npq\), where \(p+q=1\). It is a sum of \(n\) independent Bernoulli variables \(B\) where \(\mathsf{Pr}(B=1)=p\) and \(\mathsf{Pr}(B=0)=q=1-p\). The MGF for a binomial is \((q+pe^{z})^n\) and the probabilities are derived from the binomial expansion of the MGF. By analogy the negative binomial can be defined in terms of the negative binomial expansion of \((Q-Pe^{z})^{-k}\) where \(Q=1+P\), \(P>0\) and \(k>0\).

The actuary can look at the negative binomial in two different way, each of which gives different results. It is important to understand these two views. First there is the contagion view, where the mixing distribution \(G\) has mean \(n\) and variance \(c\) producing a negative binomial with mean \(n\) and variance \(n(1+cn)\). (In fact \(G\) is a gamma with model (a) parameters \(\alpha=r\) and \(\beta=1/r\).) The word contagion is used by Heckman and Meyers [1983] and is supposed to indicate a “contagion” of claim propensity driven by common shock uncertainty, such as claim inflation, economic activity, or weather. Here the variance grows with the square of \(n\) and the coefficient of variation tends to \(\sqrt{c}>0\) as \(n\to\infty\). Secondly, one can consider an over-dispersed family of Poisson variables with mean \(n\) and variance \(vn\) for some \(v>1\). We call \(v\) the variance multiplier. Now, the coefficient of variation tends to \(0\) as \(n\to\infty\). The notion of over-dispersion and its application in modeling is discussed in Clark and Thayer [2004] and Verrall [2004].

5.1.6.2. The Variance Multiplier

The variance of a mixed Poisson equals \(n(1+cn)\) where \(c\) equals the variance of the mixing distribution. Thus the variance equals \(v=1+cn\) times the mean \(n\), where \(v\) is called the variance multiplier. The variance multiplier specification is used by some US rating bureaus. The dictionary to variance and mix CV is

\[\begin{split}c &= (v-1) / n \\ \mathit{cv} &= \sqrt{(v-1)/n}.\end{split}\]

The frequency for an excess layer attaching at \(a\) equals \(nS(a)\). For fixed \(c\), the implied variance multiplier \(v=1+cnS(a)\) decreases and the excess claim count distribution converges to a Poisson. This is an example of the law of small numbers.

Per Mildenhall [2017], if \(\nu\) is the CV of \(G\) then the \(\nu\) equals the asymptotic coefficient of variation for any \(G\)-mixed compound Poisson distribution whose variance exists. The variance will exist iff the variance of the severity term exists. See When Is Severity Irrelevant?.

5.1.6.3. Negative Binomial Distribution

Negative binomial distribution describes a sequence of iid Bernoulli trials, repeated until a predefined, non-random number of successes occurs.

The probability mass function of the number of failures for nbinom is:

\[f(k) = \binom{k+n-1}{n-1} p^n (1-p)^k\]

for \(k \ge 0\), \(0 < p \leq 1\)

nbinom takes \(n\) and \(p\) as shape parameters where n is the number of successes, \(p\) is the probability of a single success, and \(1-p\) is the probability of a single failure.

Another common parameterization of the negative binomial distribution is in terms of the mean number of failures \(\mu\) to achieve \(n\) successes. The mean \(\mu\) is related to the probability of success as

\[p = \frac{n}{n + \mu}\]

The number of successes \(n\) may also be specified in terms of a “dispersion”, “heterogeneity”, or “aggregation” parameter \(\alpha\), which relates the mean \(\mu\) to the variance \(\sigma^2\), e.g. \(\sigma^2 = \mu + \alpha \mu^2\). Regardless of the convention used for \(\alpha\),

\[\begin{split}p &= \frac{\mu}{\sigma^2} \\ n &= \frac{\mu^2}{\sigma^2 - \mu}\end{split}\]

5.1.6.4. Beta Binomial Distribution

The beta-binomial distribution is a binomial distribution with a probability of success p that follows a beta distribution.

The probability mass function for betabinom is:

\[f(k) = \binom{n}{k} \frac{B(k + a, n - k + b)}{B(a, b)}\]

for \(k \in \{0, 1, \dots, n\}\), \(n \geq 0\), \(a > 0\), \(b > 0\), where \(B(a, b)\) is the beta function.

betabinom takes \(n\), \(a\), and \(b\) as shape parameters.

5.1.6.5. Shifted Mixing (General)

We can adjust the skewness of mixing with shifting. In addition to a target CV \(\nu\) assume a proportion \(f\) of claims are sure to occur. Use a mixing distribution \(G=f+G'\) such that

  • \(\mathsf E[G]= f + \mathsf E[G'] = 1\) and

  • \(\mathsf{CV}(G) = \sigma(G') = \nu\).

As \(f\) increases from 0 to 1 the skewness of \(G\) will increase. Delaporte first introduced this idea.

Since \(\mathsf{skew}(G)=\mathsf{skew}(G')\) we have \(g=\mathsf E[G^3]=\nu^3 \mathsf{skew}(G')+3c+1\).

5.1.6.5.1. Delaporte Mixing (Shifted Gamma)

Inputs are target CV \(\nu\) and proportion of certain claims \(f\), \(0\leq f \leq 1\). Find parameters \(f\), \(a\) and \(\theta\) for a shifted gamma \(G=f+G'\) with \(E(G')=1-f\) and \(SD(G')=\nu\) as

  • \(f\) is input

  • mean \(a\theta=1-s\) and \(CV=\nu=\sqrt{a}\theta\) so \(a=(1-f)^2/\nu^2=(1-f)^2/c\) and \(\theta=(1-f)/a\)

The skewness of \(G\) equals the skewness of \(G'\) equals \(2/\sqrt{a}= 2\nu/(1-f)\), which is then greater than the skewness \(2\nu\) when \(f=0\). The third non-central moment \(g=2\nu^4/(1-f)+3c+1\)

5.1.6.5.2. Poisson Inverse Gaussian Distribution

5.1.6.6. The \((a,b,0)\) and \((a,b,1)\) Classes

See Klugman et al. [2019].

5.1.7. Aggregate Distributions

Let \(A=X_1+\cdots +X_N\) be an aggregate distribution, where \(N\) is the frequency component and \(X_i\) are iid severity random variables.

5.1.7.1. Aggregate Mean

The mean of a sum equals the sum of the means. Let \(A = X_1 + \cdots + X_N\). If \(N=n\) is fixed then \(\mathsf E[A] = n\mathsf E[X]\), because all \(\mathsf E[X_i]=\mathsf E[X]\). In general,

\[\mathsf E[A] = \mathsf E[X]\mathsf E[N]\]

by conditional probability.

5.1.7.2. Aggregate Variance

The variance of a sum of independent random variables equals the sum of the variances. If \(N=n\) is fixed then \(\mathsf{Var}(A) = n\mathsf{Var}(X)\) and \(\mathsf{Var}(N)=0\). If \(X=x\) is fixed then \(\mathsf{Var}(A) = x^2\mathsf{Var}(N)\) and \(\mathsf{Var}(X)=0\). Making the obvious associations \(n\leftrightarrow\mathsf E[N]\), \(x\leftrightarrow\mathsf E[X]\) suggests

\[\mathsf{Var}(A) = \mathsf E[N]\mathsf{Var}(X) + \mathsf E[X]^2\mathsf{Var}(N).\]

Using conditional expectations and conditioning on the value of \(N\) shows this is the correct answer!

Exercise. Confirm the formulas for an aggregate mean and variance hold for the Simple Example.

5.1.7.3. Aggregate Moment Generating Function

Using the tower property of conditional expectations and the independence of \(N\) and \(X_i\) gives

\[\begin{split}M_A(z) &= \mathsf{E}[\exp(z(X_1+\cdots X_N))] \\ &= \mathsf{E}[\mathsf{E}[\exp(z(X_1+\cdots X_N)) \mid N]] \\ &= \mathsf{E}[\mathsf{E}[\exp(z X_1)^N]] \\ &= \mathsf{E}[\mathsf{E}[\exp(z X_1)]^N] \\ &= M_N(\log(M_X(z)))\end{split}\]

Differentiating and using XXs formula, yields the moments of \(A\), see below.

The last expression is very important and underlies the use of FFTs to compute aggregate distributions.

Next, specialize to the case where \(A=X_1+\cdots +X_N\) is an aggregate distribution with \(N\) a \(G\)-mixed Poisson. Then

\[\begin{split}M_A(z) &= \mathsf{E}[\exp(z(X_1+\cdots X_N))] \\ &= \mathsf{E}[\mathsf{E}[\exp(z(X_1+\cdots X_N)) \mid N]] \\ &= \mathsf{E}[\mathsf{E}[\exp(z X_1)^N]] \\ &= \mathsf{E}[\mathsf{E}[M_X(z)^N \mid G]] \\ &= \mathsf{E}[\exp(nG(M_X(z)-1))] \\ &= M_G(n(M_X(z)-1))\end{split}\]

Thus

\[\mathsf{E}[A]=M_A'(0)=n M_G'(0)M_X'(0)=n \mathsf{E}[X]\]

and

\[\begin{split}\mathsf{E}[A^2] &=M_A''(0) \\ &= n^2 M_G''(0)M_X'(0)^2+n M_G'(0)M_X''(0) \\ &= n^2\mathsf{E}[G^2]\mathsf{E}[X]^2+n\mathsf{E}[X^2].\end{split}\]

Hence, using the fact that \(\mathsf{E}[G^2]=1+c\),

we get

\[\begin{split}\mathsf{var}(A) &= n^2\mathsf{E}[G^2]\mathsf{E}[X]^2+n\mathsf{E}[X^2] - n^2\mathsf{E}[X]^2 \\ &= n^2 c \mathsf{E}[X]^2+ n \mathsf{E}[X^2] \\ &= (\mathsf{var}(N)-\mathsf{E}[N])\mathsf{E}[X]^2+\mathsf{E}[N]\mathsf{E}[X^2] \\ &= \mathsf{var}(N)\mathsf{E}[X]^2+\mathsf{E}[N]\mathsf{var}(X).\end{split}\]

Continuing along the same vein we get

\[\begin{split}\mathsf{E}[A^3]= & \mathsf{E}[N]\mathsf{E}[X^3]+\mathsf{E}[N^3]\mathsf{E}[X]^3+3\mathsf{E}[N^2]\mathsf{E}[X]\mathsf{E}[X^2] \\ &-3\mathsf{E}[N]\mathsf{E}[X]\mathsf{E}[X^2] -3\mathsf{E}[N^2]\mathsf{E}[X]^3+2\mathsf{E}[N]\mathsf{E}[X]^3.\end{split}\]

and so we can compute the skewness of \(A\), remembering that

\[\mathsf{E}[(A-\mathsf{E}[A])^3]=\mathsf{E}[A^3]-3\mathsf{E}[A^2]\mathsf{E}[A]+2\mathsf{E}[A]^3.\]

Further moments can be computed using derivatives of the moment generating function.

Having computed the mean, CV and skewness of the aggregate using these equations we can use the method of moments to fit a shifted lognormal or shifted gamma distribution. We turn next to a description of these handy distributions.

5.1.8. Shifted Gamma and Lognormal Distributions

The shifted gamma and shifted lognormal distributions are versatile three parameter distributions whose method of moments parameters can be conveniently computed by closed formula. The examples below show that they also provide a very good approximation to aggregate loss distributions. The shifted gamma approximation to an aggregate is discussed in Bowers et al. [1997]. Properties of the shifted gamma and lognormal distributions, including the method of moments fit parameters, are also shown in Daykin et al. [1993] chapter 3.

Let \(L\) have a lognormal distribution. Then \(S=s\pm L\) is a shifted lognormal, where \(s\) is a real number. Since \(s\) can be positive or negative and since \(L\) can equal \(s+L\) or \(s-L\), the shifted lognormal can model distributions which are positively or negatively skewed, as well as distributions supported on the negative reals. The key facts about the shifted lognormal are shown in Table 1.4. The variable \(\eta\) is a solution to the cubic equation

\[\eta^3 + 3\eta - \gamma=0\]

where \(\gamma\) is the skewness.

Let \(G\) have a gamma distribution. Then \(T=s\pm G\) is a shifted gamma distribution, where \(s\) is a real number. Table 1.1 shows some common parametric forms for the gamma distribution. The key facts about the shifted gamma distribution are also shown in Table 1.4.

The exponential is a special case of the gamma where \(\alpha=1\). The \(\chi^2\) is a special case where \(\alpha=k/2\) and \(\beta = 2\) in the Excel parameterization. The Pareto is a mixture of exponentials where the mixing distribution is gamma.

Shifted Gamma and Lognormal Distributions

Item

Shifted Gamma

Shifted Lognormal

Parameters

\(s\), \(\alpha\), \(\theta\)

\(s\), \(\mu\), \(\sigma\)

Mean \(m\)

\(s+\alpha\theta\)

\(s+\exp(\mu+\sigma^2/2)\)

Variance

\(\alpha\theta^2\)

\(m^2\exp(\sigma^2-1)\)

CV, \(\nu\)

\(\sqrt{\alpha}\beta/\gamma\)

\(\exp((\sigma^2-1)/2)\)

Skewness,

\(2/\sqrt{\alpha}\)

\(\gamma=\nu(\nu^2+3)\)

Method of Moments Parameters

\(\eta\)

n/a

\(\eta=u-1/u\) where

\(u^3=\sqrt{\gamma^2+4}/2+\gamma/2\)

Shift variable, \(s\)

\(m-\alpha\beta\)

\(m(1-\nu\eta)\)

\(\alpha\) or \(\sigma\)

\(4/\gamma^2\)

\(\sqrt{\ln(1+\eta^2)}\)

\(\beta\) or \(\mu\)

\(m\nu\gamma/2\)

\(\ln(m-s)-\sigma^2/2\)

5.1.9. Appendix: Selected scipy.stats Discrete Random Variables

Here is the list of scipy.stats discrete random variables.

                         Num. args   Min range   Max range Parameters
Distribution
bernoulli                         1           0           1 'p'
dlaplace                          1        -inf         inf 'a'
geom                              1           1         inf 'p'
logser                            1           1         inf 'p'
planck                            1           0         inf 'lambda\_'
poisson                           1           0         inf 'mu'
yulesimon                         1           1         inf 'alpha'
zipf                              1           1         inf 'a'
binom                             2           0         inf 'n' and 'p'
boltzmann                         2           0         inf 'lambda\_' and 'N'
nbinom                            2           0         inf 'n' and 'p'
randint                           2           0         inf 'low' and 'high'
skellam                           2        -inf         inf 'mu1' and 'mu2'
zipfian                           2           1         inf 'a' and 'n'
betabinom                         3           0         inf 'n', 'a', and 'b'
hypergeom                         3           0         inf 'M', 'n', and 'N'
nhypergeom                        3           0         inf 'M', 'n', and 'r'
nchypergeom_fisher                4           0         inf 'M', 'n', 'N', and 'odds'
nchypergeom_wallenius             4           0         inf 'M', 'n', 'N', and 'odds'
  • bernoulli Bernoulli (help). The probability mass function for bernoulli is:

    \[\begin{split}f(k) = \begin{cases}1-p &\text{if } k = 0\\ p &\text{if } k = 1\end{cases}\end{split}\]

    for \(k\) in \(\{0, 1\}\), \(0 \leq p \leq 1\)

    bernoulli takes \(p\) as shape parameter, where \(p\) is the probability of a single success and \(1-p\) is the probability of a single failure.

    The probability mass function above is defined in the “standardized” form. To shift distribution use the loc parameter. Specifically, bernoulli.pmf(k, p, loc) is identically equivalent to bernoulli.pmf(k - loc, p).

  • betabinom Betabinom (help). The beta-binomial distribution is a binomial distribution with a

    probability of success p that follows a beta distribution.

    The probability mass function for betabinom is:

    \[f(k) = \binom{n}{k} \frac{B(k + a, n - k + b)}{B(a, b)}\]

    for \(k \in \{0, 1, \dots, n\}\), \(n \geq 0\), \(a > 0\), \(b > 0\), where \(B(a, b)\) is the beta function.

    betabinom takes \(n\), \(a\), and \(b\) as shape parameters.

  • binom Binom (help). The probability mass function for binom is:

    \[f(k) = \binom{n}{k} p^k (1-p)^{n-k}\]

    for \(k \in \{0, 1, \dots, n\}\), \(0 \leq p \leq 1\)

    binom takes \(n\) and \(p\) as shape parameters, where \(p\) is the probability of a single success and \(1-p\) is the probability of a single failure.

  • boltzmann Boltzmann (help). The probability mass function for boltzmann is:

    \[f(k) = (1-\exp(-\lambda)) \exp(-\lambda k) / (1-\exp(-\lambda N))\]

    for \(k = 0,..., N-1\).

    boltzmann takes \(\lambda > 0\) and \(N > 0\) as shape parameters.

  • geom Geom (help). The probability mass function for geom is:

    \[f(k) = (1-p)^{k-1} p\]

    for \(k \ge 1\), \(0 < p \leq 1\)

    geom takes \(p\) as shape parameter, where \(p\) is the probability of a single success and \(1-p\) is the probability of a single failure.

  • logser Logser (help). The probability mass function for logser is:

    \[f(k) = - \frac{p^k}{k \log(1-p)}\]

    for \(k \ge 1\), \(0 < p < 1\)

    logser takes \(p\) as shape parameter, where \(p\) is the probability of a single success and \(1-p\) is the probability of a single failure.

  • nbinom Nbinom (help). Negative binomial distribution describes a sequence of i.i.d. Bernoulli

    trials, repeated until a predefined, non-random number of successes occurs.

    The probability mass function of the number of failures for nbinom is:

    \[f(k) = \binom{k+n-1}{n-1} p^n (1-p)^k\]

    for \(k \ge 0\), \(0 < p \leq 1\)

    nbinom takes \(n\) and \(p\) as shape parameters where n is the number of successes, \(p\) is the probability of a single success, and \(1-p\) is the probability of a single failure.

    Another common parameterization of the negative binomial distribution is in terms of the mean number of failures \(\mu\) to achieve \(n\) successes. The mean \(\mu\) is related to the probability of success as

    \[p = \frac{n}{n + \mu}\]

    The number of successes \(n\) may also be specified in terms of a “dispersion”, “heterogeneity”, or “aggregation” parameter \(\alpha\), which relates the mean \(\mu\) to the variance \(\sigma^2\), e.g. \(\sigma^2 = \mu + \alpha \mu^2\). Regardless of the convention used for \(\alpha\),

    \[\begin{split}p &= \frac{\mu}{\sigma^2} \\ n &= \frac{\mu^2}{\sigma^2 - \mu}\end{split}\]
  • planck Planck (help). The probability mass function for planck is:

    \[f(k) = (1-\exp(-\lambda)) \exp(-\lambda k)\]

    for \(k \ge 0\) and \(\lambda > 0\).

    planck takes \(\lambda\) as shape parameter. The Planck distribution can be written as a geometric distribution (geom) with \(p = 1 - \exp(-\lambda)\) shifted by loc = -1.

  • poisson Poisson (help). The probability mass function for poisson is:

    \[f(k) = \exp(-\mu) \frac{\mu^k}{k!}\]

    for \(k \ge 0\).

    poisson takes \(\mu \geq 0\) as shape parameter. When \(\mu = 0\), the pmf method returns 1.0 at quantile \(k = 0\).

  • randint Randint (help). The probability mass function for randint is:

    \[f(k) = \frac{1}{\texttt{high} - \texttt{low}}\]

    for \(k \in \{\texttt{low}, \dots, \texttt{high} - 1\}\).

    randint takes \(\texttt{low}\) and \(\texttt{high}\) as shape parameters.

5.1.10. Appendix: scipy.stats Continuous Random Variables

The information below was extracted from the scipy help for continuous distributions. The basic list can be created by introspection—wonderful Python!

In [1]: import scipy.stats as ss

In [2]: import pandas as pd

In [3]: ans = []

In [4]: for k in dir(ss):
   ...:     ob = getattr(ss, k)
   ...:     if str(type(ob)).find('continuous_distns') > 0:
   ...:         try:
   ...:             fz = ob()
   ...:         except TypeError as e:
   ...:             ee = e
   ...:             ans.append([k, str(e), -1, ob.a, ob.b])
   ...:         else:
   ...:             ans.append([k, 'no args fine', 0, ob.a, ob.b])
   ...: 

In [5]: df = pd.DataFrame(ans, columns=['dist', 'm', 'args', 'a', 'b'])

In [6]: for i in range(1,5):
   ...:     df.loc[df.m.str.find(f'{i} required')>=0, 'args'] = i
   ...: 

In [7]: df = df.sort_values(['args', 'dist'])

In [8]: df['params'] = ''

In [9]: df.loc[df.args > 0, 'params'] = df.loc[df.args > 0, 'm'].str.split(':').str[1]

In [10]: df = df.drop(columns='m')

In [11]: print(df.rename(columns={'dist': 'Distribution', 'args': 'Num. args',
   ....:         'a': 'Min range' , 'b': 'Max range', 'params': 'Parameters'}).\
   ....:         set_index('Distribution').to_string(float_format=lambda x: f'{x:.4g}'))
   ....: 
                    Num. args  Min range  Max range               Parameters
Distribution                                                                
anglit                      0    -0.7854     0.7854                         
arcsine                     0          0          1                         
cauchy                      0       -inf        inf                         
cosine                      0     -3.142      3.142                         
expon                       0          0        inf                         
gibrat                      0          0        inf                         
gumbel_l                    0       -inf        inf                         
gumbel_r                    0       -inf        inf                         
halfcauchy                  0          0        inf                         
halflogistic                0          0        inf                         
halfnorm                    0          0        inf                         
hypsecant                   0       -inf        inf                         
kstwobign                   0          0        inf                         
laplace                     0       -inf        inf                         
levy                        0          0        inf                         
levy_l                      0       -inf          0                         
logistic                    0       -inf        inf                         
maxwell                     0          0        inf                         
moyal                       0       -inf        inf                         
norm                        0       -inf        inf                         
rayleigh                    0          0        inf                         
semicircular                0         -1          1                         
uniform                     0          0          1                         
wald                        0          0        inf                         
alpha                       1          0        inf                      'a'
argus                       1          0          1                    'chi'
bradford                    1          0          1                      'c'
chi                         1          0        inf                     'df'
chi2                        1          0        inf                     'df'
dgamma                      1       -inf        inf                      'a'
dweibull                    1       -inf        inf                      'c'
erlang                      1          0        inf                      'a'
exponnorm                   1       -inf        inf                      'K'
exponpow                    1          0        inf                      'b'
fatiguelife                 1          0        inf                      'c'
fisk                        1          0        inf                      'c'
foldcauchy                  1          0        inf                      'c'
foldnorm                    1          0        inf                      'c'
gamma                       1          0        inf                      'a'
genextreme                  1       -inf        inf                      'c'
genhalflogistic             1          0        inf                      'c'
genlogistic                 1       -inf        inf                      'c'
gennorm                     1       -inf        inf                   'beta'
genpareto                   1          0        inf                      'c'
gompertz                    1          0        inf                      'c'
halfgennorm                 1          0        inf                   'beta'
invgamma                    1          0        inf                      'a'
invgauss                    1          0        inf                     'mu'
invweibull                  1          0        inf                      'c'
kappa3                      1          0        inf                      'a'
ksone                       1          0          1                      'n'
kstwo                       1          0          1                      'n'
laplace_asymmetric          1       -inf        inf                  'kappa'
loggamma                    1       -inf        inf                      'c'
loglaplace                  1          0        inf                      'c'
lognorm                     1          0        inf                      's'
lomax                       1          0        inf                      'c'
nakagami                    1          0        inf                     'nu'
pareto                      1          1        inf                      'b'
pearson3                    1       -inf        inf                   'skew'
powerlaw                    1          0          1                      'a'
powernorm                   1       -inf        inf                      'c'
rdist                       1         -1          1                      'c'
recipinvgauss               1          0        inf                     'mu'
rel_breitwigner             1          0        inf                    'rho'
rice                        1          0        inf                      'b'
skewcauchy                  1       -inf        inf                      'a'
skewnorm                    1       -inf        inf                      'a'
t                           1       -inf        inf                     'df'
triang                      1          0          1                      'c'
truncexpon                  1          0        inf                      'b'
tukeylambda                 1       -inf        inf                    'lam'
vonmises                    1       -inf        inf                  'kappa'
vonmises_line               1     -3.142      3.142                  'kappa'
weibull_max                 1       -inf          0                      'c'
weibull_min                 1          0        inf                      'c'
wrapcauchy                  1          0      6.283                      'c'
beta                        2          0          1              'a' and 'b'
betaprime                   2          0        inf              'a' and 'b'
burr                        2          0        inf              'c' and 'd'
burr12                      2          0        inf              'c' and 'd'
crystalball                 2       -inf        inf           'beta' and 'm'
exponweib                   2          0        inf              'a' and 'c'
f                           2          0        inf          'dfn' and 'dfd'
gengamma                    2          0        inf              'a' and 'c'
geninvgauss                 2          0        inf              'p' and 'b'
jf_skew_t                   2       -inf        inf              'a' and 'b'
johnsonsb                   2          0          1              'a' and 'b'
johnsonsu                   2       -inf        inf              'a' and 'b'
kappa4                      2       -inf        inf              'h' and 'k'
loguniform                  2       -inf        inf              'a' and 'b'
mielke                      2          0        inf              'k' and 's'
nct                         2       -inf        inf            'df' and 'nc'
ncx2                        2          0        inf            'df' and 'nc'
norminvgauss                2       -inf        inf              'a' and 'b'
powerlognorm                2          0        inf              'c' and 's'
reciprocal                  2       -inf        inf              'a' and 'b'
studentized_range           2          0        inf             'k' and 'df'
trapezoid                   2          0          1              'c' and 'd'
trapz                       2          0          1              'c' and 'd'
truncnorm                   2       -inf        inf              'a' and 'b'
truncpareto                 2          1        inf              'b' and 'c'
genexpon                    3          0        inf        'a', 'b', and 'c'
genhyperbolic               3       -inf        inf        'p', 'a', and 'b'
ncf                         3          0        inf   'dfn', 'dfd', and 'nc'
truncweibull_min            3       -inf        inf        'c', 'a', and 'b'
gausshyper                  4          0          1   'a', 'b', 'c', and 'z'
  • alpha Alpha (help). The probability density function for alpha is:

    \[f(x, a) = \frac{1}{x^2 \Phi(a) \sqrt{2\pi}} * \exp(-\frac{1}{2} (a-1/x)^2)\]

    where \(\Phi\) is the normal CDF, \(x > 0\), and \(a > 0\).

    alpha takes a as a shape parameter.

  • anglit Anglit (help). The probability density function for anglit is:

    \[f(x) = \sin(2x + \pi/2) = \cos(2x)\]

    for \(-\pi/4 \le x \le \pi/4\).

  • arcsine Arcsine (help). The probability density function for arcsine is:

    \[f(x) = \frac{1}{\pi \sqrt{x (1-x)}}\]

    for \(0 < x < 1\).

  • argus Argus (help). The probability density function for argus is:

    \[f(x, \chi) = \frac{\chi^3}{\sqrt{2\pi} \Psi(\chi)} x \sqrt{1-x^2} \exp(-\chi^2 (1 - x^2)/2)\]

    for \(0 < x < 1\) and \(\chi > 0\), where

    \[\Psi(\chi) = \Phi(\chi) - \chi \phi(\chi) - 1/2\]

    with \(\Phi\) and \(\phi\) being the CDF and PDF of a standard normal distribution, respectively.

    argus takes \(\chi\) as shape a parameter.

  • beta Beta (help). The probability density function for beta is:

    \[f(x, a, b) = \frac{\Gamma(a+b) x^{a-1} (1-x)^{b-1}} {\Gamma(a) \Gamma(b)}\]

    for \(0 <= x <= 1\), \(a > 0\), \(b > 0\), where \(\Gamma\) is the gamma function (scipy.special.gamma).

    beta takes \(a\) and \(b\) as shape parameters.

  • betaprime Beta Prime (help). The probability density function for betaprime is:

    \[f(x, a, b) = \frac{x^{a-1} (1+x)^{-a-b}}{\beta(a, b)}\]

    for \(x >= 0\), \(a > 0\), \(b > 0\), where \(\beta(a, b)\) is the beta function (see scipy.special.beta).

    betaprime takes a and b as shape parameters.

  • bradford Bradford (help). The probability density function for bradford is:

    \[f(x, c) = \frac{c}{\log(1+c) (1+cx)}\]

    for \(0 <= x <= 1\) and \(c > 0\).

    bradford takes c as a shape parameter for \(c\).

  • burr Burr (Type III) (help). The probability density function for burr is:

    \[f(x, c, d) = c d x^{-c - 1} / (1 + x^{-c})^{d + 1}\]

    for \(x >= 0\) and \(c, d > 0\).

    burr takes \(c\) and \(d\) as shape parameters.

    This is the PDF corresponding to the third CDF given in Burr’s list; specifically, it is equation (11) in Burr’s paper. The distribution is also commonly referred to as the Dagum distribution. If the parameter \(c < 1\) then the mean of the distribution does not exist and if \(c < 2\) the variance does not exist. The PDF is finite at the left endpoint \(x = 0\) if \(c * d >= 1\).

  • burr12 Burr (Type XII) (help). The probability density function for burr is:

    \[f(x, c, d) = c d x^{c-1} / (1 + x^c)^{d + 1}\]

    for \(x >= 0\) and \(c, d > 0\).

    burr12 takes c and d as shape parameters for \(c\) and \(d\).

    This is the PDF corresponding to the twelfth CDF given in Burr’s list; specifically, it is equation (20) in Burr’s paper.

  • cauchy Cauchy (help). The probability density function for cauchy is

    \[f(x) = \frac{1}{\pi (1 + x^2)}\]

    for a real number \(x\).

  • chi Chi (help). The probability density function for chi is:

    \[f(x, k) = \frac{1}{2^{k/2-1} \Gamma \left( k/2 \right)} x^{k-1} \exp \left( -x^2/2 \right)\]

    for \(x >= 0\) and \(k > 0\) (degrees of freedom, denoted df in the implementation). \(\Gamma\) is the gamma function (scipy.special.gamma).

    Special cases of chi are:

    • chi(1, loc, scale) is equivalent to halfnorm

    • chi(2, 0, scale) is equivalent to rayleigh

    • chi(3, 0, scale) is equivalent to maxwell

    chi takes df as a shape parameter.

  • chi2 Chi-squared (help). The probability density function for chi2 is:

    \[f(x, k) = \frac{1}{2^{k/2} \Gamma \left( k/2 \right)} x^{k/2-1} \exp \left( -x/2 \right)\]

    for \(x > 0\) and \(k > 0\) (degrees of freedom, denoted df in the implementation).

    chi2 takes df as a shape parameter.

    The chi-squared distribution is a special case of the gamma distribution, with gamma parameters a = df/2, loc = 0 and scale = 2.

  • cosine Cosine (help). The cosine distribution is an approximation to the normal distribution. The probability density function for cosine is:

    \[f(x) = \frac{1}{2\pi} (1+\cos(x))\]

    for \(-\pi \le x \le \pi\).

  • crystalball Crystalball (help). The probability density function for crystalball is:

    \[\begin{split}f(x, \beta, m) = \begin{cases} N \exp(-x^2 / 2), &\text{for } x > -\beta\\ N A (B - x)^{-m} &\text{for } x \le -\beta \end{cases}\end{split}\]

    where \(A = (m / |\beta|)^m \exp(-\beta^2 / 2)\), \(B = m/|\beta| - |\beta|\) and \(N\) is a normalisation constant.

    crystalball takes \(\beta > 0\) and \(m > 1\) as shape parameters. \(\beta\) defines the point where the pdf changes from a power-law to a Gaussian distribution. \(m\) is the power of the power-law tail.

  • dgamma Double Gamma (help). The probability density function for dgamma is:

    \[f(x, a) = \frac{1}{2\Gamma(a)} |x|^{a-1} \exp(-|x|)\]

    for a real number \(x\) and \(a > 0\). \(\Gamma\) is the gamma function (scipy.special.gamma).

    dgamma takes a as a shape parameter for \(a\).

  • dweibull Double Weibull (help). The probability density function for dweibull is given by

    \[f(x, c) = c / 2 |x|^{c-1} \exp(-|x|^c)\]

    for a real number \(x\) and \(c > 0\).

    dweibull takes c as a shape parameter for \(c\).

  • erlang Erlang (help). The Erlang distribution is a special case of the Gamma distribution, with the shape parameter a an integer. Note that this restriction is not enforced by erlang. It will, however, generate a warning the first time a non-integer value is used for the shape parameter.

    Refer to gamma for examples.

  • expon Exponential (help). The probability density function for expon is:

    \[f(x) = \exp(-x)\]

    for \(x \ge 0\).

  • exponnorm Exponentially Modified Normal (help). The probability density function for exponnorm is:

    \[f(x, K) = \frac{1}{2K} \exp\left(\frac{1}{2 K^2} - x / K \right) \text{erfc}\left(-\frac{x - 1/K}{\sqrt{2}}\right)\]

    where \(x\) is a real number and \(K > 0\).

    It can be thought of as the sum of a standard normal random variable and an independent exponentially distributed random variable with rate 1/K.

  • exponweib Exponentiated Weibull (help). The probability density function for exponweib is:

    \[f(x, a, c) = a c [1-\exp(-x^c)]^{a-1} \exp(-x^c) x^{c-1}\]

    and its cumulative distribution function is:

    \[F(x, a, c) = [1-\exp(-x^c)]^a\]

    for \(x > 0\), \(a > 0\), \(c > 0\).

    exponweib takes \(a\) and \(c\) as shape parameters:

    • \(a\) is the exponentiation parameter, with the special case \(a=1\) corresponding to the (non-exponentiated) Weibull distribution weibull_min.

    • \(c\) is the shape parameter of the non-exponentiated Weibull law.

  • exponpow Exponential Power (help). The probability density function for exponpow is:

    \[f(x, b) = b x^{b-1} \exp(1 + x^b - \exp(x^b))\]

    for \(x \ge 0\), \(b > 0\). Note that this is a different distribution from the exponential power distribution that is also known under the names “generalized normal” or “generalized Gaussian”.

    exponpow takes b as a shape parameter for \(b\).

  • f F (Snecdor F) (help). The probability density function for f is:

    \[f(x, df_1, df_2) = \frac{df_2^{df_2/2} df_1^{df_1/2} x^{df_1 / 2-1}} {(df_2+df_1 x)^{(df_1+df_2)/2} B(df_1/2, df_2/2)}\]

    for \(x > 0\).

    f takes dfn and dfd as shape parameters.

  • fatiguelife Fatigue Life (Birnbaum-Saunders) (help). The probability density function for fatiguelife is:

    \[f(x, c) = \frac{x+1}{2c\sqrt{2\pi x^3}} \exp(-\frac{(x-1)^2}{2x c^2})\]

    for \(x >= 0\) and \(c > 0\).

    fatiguelife takes c as a shape parameter for \(c\).

  • fisk Fisk (help). The probability density function for fisk is:

    \[f(x, c) = c x^{-c-1} (1 + x^{-c})^{-2}\]

    for \(x >= 0\) and \(c > 0\).

    fisk takes c as a shape parameter for \(c\).

    fisk is a special case of burr or burr12 with d=1.

  • foldcauchy Folded Cauchy (help). The probability density function for foldcauchy is:

    \[f(x, c) = \frac{1}{\pi (1+(x-c)^2)} + \frac{1}{\pi (1+(x+c)^2)}\]

    for \(x \ge 0\).

    foldcauchy takes c as a shape parameter for \(c\).

  • foldnorm Folded Normal (help). The probability density function for foldnorm is:

    \[f(x, c) = \sqrt{2/\pi} cosh(c x) \exp(-\frac{x^2+c^2}{2})\]

    for \(c \ge 0\).

    foldnorm takes c as a shape parameter for \(c\).

  • genlogistic Generalized Logistic (help). The probability density function for genlogistic is:

    \[f(x, c) = c \frac{\exp(-x)} {(1 + \exp(-x))^{c+1}}\]

    for \(x >= 0\), \(c > 0\).

    genlogistic takes c as a shape parameter for \(c\).

  • gennorm Generalized normal (help). The probability density function for gennorm is:

    \[f(x, \beta) = \frac{\beta}{2 \Gamma(1/\beta)} \exp(-|x|^\beta)\]

    \(\Gamma\) is the gamma function (scipy.special.gamma).

    gennorm takes beta as a shape parameter for \(\beta\). For \(\beta = 1\), it is identical to a Laplace distribution. For \(\beta = 2\), it is identical to a normal distribution (with scale=1/sqrt(2)).

  • genpareto Generalized Pareto (help). The probability density function for genpareto is:

    \[f(x, c) = (1 + c x)^{-1 - 1/c}\]

    defined for \(x \ge 0\) if \(c \ge 0\), and for \(0 \le x \le -1/c\) if \(c < 0\).

    genpareto takes c as a shape parameter for \(c\).

    For \(c=0\), genpareto reduces to the exponential distribution, expon:

    \[f(x, 0) = \exp(-x)\]

    For \(c=-1\), genpareto is uniform on [0, 1]:

    \[f(x, -1) = 1\]
  • genexpon Generalized Exponential (help). The probability density function for genexpon is:

    \[f(x, a, b, c) = (a + b (1 - \exp(-c x))) \exp(-a x - b x + \frac{b}{c} (1-\exp(-c x)))\]

    for \(x \ge 0\), \(a, b, c > 0\).

    genexpon takes \(a\), \(b\) and \(c\) as shape parameters.

  • genextreme Generalized Extreme Value (help). For \(c=0\), genextreme is equal to gumbel_r. The probability density function for genextreme is:

    \[\begin{split}f(x, c) = \begin{cases} \exp(-\exp(-x)) \exp(-x) &\text{for } c = 0\\ \exp(-(1-c x)^{1/c}) (1-c x)^{1/c-1} &\text{for } x \le 1/c, c > 0 \end{cases}\end{split}\]

    Note that several sources and software packages use the opposite convention for the sign of the shape parameter \(c\).

    genextreme takes c as a shape parameter for \(c\).

  • gausshyper Gauss Hypergeometric (help). The probability density function for gausshyper is:

    \[f(x, a, b, c, z) = C x^{a-1} (1-x)^{b-1} (1+zx)^{-c}\]

    for \(0 \le x \le 1\), \(a > 0\), \(b > 0\), \(z > -1\), and \(C = \frac{1}{B(a, b) F[2, 1](c, a; a+b; -z)}\). \(F[2, 1]\) is the Gauss hypergeometric function scipy.special.hyp2f1.

    gausshyper takes \(a\), \(b\), \(c\) and \(z\) as shape parameters.

  • gamma Gamma (help). The probability density function for gamma is:

    \[f(x, a) = \frac{x^{a-1} e^{-x}}{\Gamma(a)}\]

    for \(x \ge 0\), \(a > 0\). Here \(\Gamma(a)\) refers to the gamma function.

    gamma takes a as a shape parameter for \(a\).

    When \(a\) is an integer, gamma reduces to the Erlang distribution, and when \(a=1\) to the exponential distribution.

    Gamma distributions are sometimes parameterized with two variables, with a probability density function of:

    \[f(x, \alpha, \beta) = \frac{\beta^\alpha x^{\alpha - 1} e^{-\beta x }}{\Gamma(\alpha)}\]

    Note that this parameterization is equivalent to the above, with scale = 1 / beta.

  • gengamma Generalized gamma (help). The probability density function for gengamma is:

    \[f(x, a, c) = \frac{|c| x^{c a-1} \exp(-x^c)}{\Gamma(a)}\]

    for \(x \ge 0\), \(a > 0\), and \(c \ne 0\). \(\Gamma\) is the gamma function (scipy.special.gamma).

    gengamma takes \(a\) and \(c\) as shape parameters.

  • genhalflogistic Generalized Half Logistic (help). The probability density function for genhalflogistic is:

    \[f(x, c) = \frac{2 (1 - c x)^{1/(c-1)}}{[1 + (1 - c x)^{1/c}]^2}\]

    for \(0 \le x \le 1/c\), and \(c > 0\).

    genhalflogistic takes c as a shape parameter for \(c\).

  • genhyperbolic Generalized Hyperbolic (help). The probability density function for genhyperbolic is:

    \[f(x, p, a, b) = \frac{(a^2 - b^2)^{p/2}} {\sqrt{2\pi}a^{p-0.5} K_p\Big(\sqrt{a^2 - b^2}\Big)} e^{bx} \times \frac{K_{p - 1/2} (a \sqrt{1 + x^2})} {(\sqrt{1 + x^2})^{1/2 - p}}\]

    for \(x, p \in ( - \infty; \infty)\), \(|b| < a\) if \(p \ge 0\), \(|b| \le a\) if \(p < 0\). \(K_{p}(.)\) denotes the modified Bessel function of the second kind and order \(p\) (scipy.special.kn)

    genhyperbolic takes p as a tail parameter, a as a shape parameter, b as a skewness parameter.

  • geninvgauss Generalized Inverse Gaussian (help). The probability density function for geninvgauss is:

    \[f(x, p, b) = x^{p-1} \exp(-b (x + 1/x) / 2) / (2 K_p(b))\]

    where x > 0, and the parameters p, b satisfy b > 0. \(K_p\) is the modified Bessel function of second kind of order p (scipy.special.kv).

  • gilbrat Gilbrat (help). The probability density function for gilbrat is:

    \[f(x) = \frac{1}{x \sqrt{2\pi}} \exp(-\frac{1}{2} (\log(x))^2)\]

    gilbrat is a special case of lognorm with s=1.

  • gompertz Gompertz (Truncated Gumbel) (help). The probability density function for gompertz is:

    \[f(x, c) = c \exp(x) \exp(-c (e^x-1))\]

    for \(x \ge 0\), \(c > 0\).

    gompertz takes c as a shape parameter for \(c\).

  • gumbel_r (help). The probability density function for gumbel_r is:

    \[f(x) = \exp(-(x + e^{-x}))\]

    The Gumbel distribution is sometimes referred to as a type I Fisher-Tippett distribution. It is also related to the extreme value distribution, log-Weibull and Gompertz distributions.

  • gumbel_l (help). The probability density function for gumbel_l is:

    \[f(x) = \exp(x - e^x)\]

    The Gumbel distribution is sometimes referred to as a type I Fisher-Tippett distribution. It is also related to the extreme value distribution, log-Weibull and Gompertz distributions.

  • halfcauchy Half Cauchy (help). The probability density function for halfcauchy is:

    \[f(x) = \frac{2}{\pi (1 + x^2)}\]

    for \(x \ge 0\).

  • halflogistic Half Logistic (help). The probability density function for halflogistic is:

    \[f(x) = \frac{ 2 e^{-x} }{ (1+e^{-x})^2 } = \frac{1}{2} \text{sech}(x/2)^2\]

    for \(x \ge 0\).

  • halfnorm Half Normal (help). The probability density function for halfnorm is:

    \[f(x) = \sqrt{2/\pi} \exp(-x^2 / 2)\]

    for \(x >= 0\).

    halfnorm is a special case of chi with df=1.

  • halfgennorm Generalized Half Normal (help). The probability density function for halfgennorm is:

    \[f(x, \beta) = \frac{\beta}{\Gamma(1/\beta)} \exp(-|x|^\beta)\]

    for \(x > 0\). \(\Gamma\) is the gamma function (scipy.special.gamma).

    gennorm takes beta as a shape parameter for \(\beta\). For \(\beta = 1\), it is identical to an exponential distribution. For \(\beta = 2\), it is identical to a half normal distribution (with scale=1/sqrt(2)).

  • hypsecant Hyperbolic Secant (help). The probability density function for hypsecant is:

    \[f(x) = \frac{1}{\pi} \text{sech}(x)\]

    for a real number \(x\).

  • invgamma Inverse Gamma (help). The probability density function for invgamma is:

    \[f(x, a) = \frac{x^{-a-1}}{\Gamma(a)} \exp(-\frac{1}{x})\]

    for \(x >= 0\), \(a > 0\). \(\Gamma\) is the gamma function (scipy.special.gamma).

    invgamma takes a as a shape parameter for \(a\).

    invgamma is a special case of gengamma with c=-1, and it is a different parameterization of the scaled inverse chi-squared distribution. Specifically, if the scaled inverse chi-squared distribution is parameterized with degrees of freedom \(\nu\) and scaling parameter \(\tau^2\), then it can be modeled using invgamma with a= \(\nu/2\) and scale= \(\nu \tau^2/2\).

  • invgauss Inverse Gaussian (help). The probability density function for invgauss is:

    \[f(x, \mu) = \frac{1}{\sqrt{2 \pi x^3}} \exp(-\frac{(x-\mu)^2}{2 x \mu^2})\]

    for \(x >= 0\) and \(\mu > 0\).

    invgauss takes mu as a shape parameter for \(\mu\).

  • invweibull Inverse Weibull (help). The probability density function for invweibull is:

    \[f(x, c) = c x^{-c-1} \exp(-x^{-c})\]

    for \(x > 0\), \(c > 0\).

    invweibull takes c as a shape parameter for \(c\).

  • johnsonsb Johnson SB (help). The probability density function for johnsonsb is:

    \[f(x, a, b) = \frac{b}{x(1-x)} \phi(a + b \log \frac{x}{1-x} )\]

    where \(x\), \(a\), and \(b\) are real scalars; \(b > 0\) and \(x \in [0,1]\). \(\phi\) is the pdf of the normal distribution.

    johnsonsb takes \(a\) and \(b\) as shape parameters.

  • johnsonsu Johnson SU (help). The probability density function for johnsonsu is:

    \[f(x, a, b) = \frac{b}{\sqrt{x^2 + 1}} \phi(a + b \log(x + \sqrt{x^2 + 1}))\]

    where \(x\), \(a\), and \(b\) are real scalars; \(b > 0\). \(\phi\) is the pdf of the normal distribution.

    johnsonsu takes \(a\) and \(b\) as shape parameters.

  • kappa4 Kappa 4 parameter (help). The probability density function for kappa4 is:

    \[f(x, h, k) = (1 - k x)^{1/k - 1} (1 - h (1 - k x)^{1/k})^{1/h-1}\]

    if \(h\) and \(k\) are not equal to 0.

    If \(h\) or \(k\) are zero then the pdf can be simplified:

    h = 0 and k != 0:

    kappa4.pdf(x, h, k) = (1.0 - k*x)**(1.0/k - 1.0)*
                          exp(-(1.0 - k*x)**(1.0/k))
    

    h != 0 and k = 0:

    kappa4.pdf(x, h, k) = exp(-x)*(1.0 - h*exp(-x))**(1.0/h - 1.0)
    

    h = 0 and k = 0:

    kappa4.pdf(x, h, k) = exp(-x)*exp(-exp(-x))
    

    kappa4 takes \(h\) and \(k\) as shape parameters.

    The kappa4 distribution returns other distributions when certain \(h\) and \(k\) values are used.

    h

    k=0.0

    k=1.0

    -inf<=k<=inf

    -1.0

    Logistic

    logistic(x)

    Generalized Logistic(1)

    0.0

    Gumbel

    gumbel_r(x)

    Reverse Exponential(2)

    Generalized Extreme Value

    genextreme(x, k)

    1.0

    Exponential

    expon(x)

    Uniform

    uniform(x)

    Generalized Pareto

    genpareto(x, -k)

  • kappa3 Kappa 3 parameter (help). The probability density function for kappa3 is:

    \[f(x, a) = a (a + x^a)^{-(a + 1)/a}\]

    for \(x > 0\) and \(a > 0\).

    kappa3 takes a as a shape parameter for \(a\).

  • ksone Distribution of Kolmogorov-Smirnov one-sided test statistic (help). \(D_n^+\) and \(D_n^-\) are given by

    \[\begin{split}D_n^+ &= \text{sup}_x (F_n(x) - F(x)),\\ D_n^- &= \text{sup}_x (F(x) - F_n(x)),\\\end{split}\]

    where \(F\) is a continuous CDF and \(F_n\) is an empirical CDF. ksone describes the distribution under the null hypothesis of the KS test that the empirical CDF corresponds to \(n\) i.i.d. random variates with CDF \(F\).

  • kstwo Distribution of Kolmogorov-Smirnov two-sided test statistic (help). \(D_n\) is given by

    \[D_n = \text{sup}_x |F_n(x) - F(x)|\]

    where \(F\) is a (continuous) CDF and \(F_n\) is an empirical CDF. kstwo describes the distribution under the null hypothesis of the KS test that the empirical CDF corresponds to \(n\) i.i.d. random variates with CDF \(F\).

  • kstwobign Limiting Distribution of scaled Kolmogorov-Smirnov two-sided test statistic. (help). \(\sqrt{n} D_n\) is given by

    \[D_n = \text{sup}_x |F_n(x) - F(x)|\]

    where \(F\) is a continuous CDF and \(F_n\) is an empirical CDF. kstwobign describes the asymptotic distribution (i.e. the limit of \(\sqrt{n} D_n\)) under the null hypothesis of the KS test that the empirical CDF corresponds to i.i.d. random variates with CDF \(F\).

  • laplace Laplace (help). The probability density function for laplace is

    \[f(x) = \frac{1}{2} \exp(-|x|)\]

    for a real number \(x\).

  • laplace_asymmetric (help). The probability density function for laplace_asymmetric is

    \[\begin{split}f(x, \kappa) &= \frac{1}{\kappa+\kappa^{-1}}\exp(-x\kappa),\quad x\ge0\\ &= \frac{1}{\kappa+\kappa^{-1}}\exp(x/\kappa),\quad x<0\\\end{split}\]

    for \(-\infty < x < \infty\), \(\kappa > 0\).

    laplace_asymmetric takes kappa as a shape parameter for \(\kappa\). For \(\kappa = 1\), it is identical to a Laplace distribution.

  • levy Levy (help). The probability density function for levy is:

    \[f(x) = \frac{1}{\sqrt{2\pi x^3}} \exp\left(-\frac{1}{2x}\right)\]

    for \(x >= 0\).

    This is the same as the Levy-stable distribution with \(a=1/2\) and \(b=1\).

  • logistic Logistic (help). The probability density function for logistic is:

    \[f(x) = \frac{\exp(-x)} {(1+\exp(-x))^2}\]

    logistic is a special case of genlogistic with c=1.

    Remark that the survival function (logistic.sf) is equal to the Fermi-Dirac distribution describing fermionic statistics.

  • loggamma Log-Gamma (help). The probability density function for loggamma is:

    \[f(x, c) = \frac{\exp(c x - \exp(x))} {\Gamma(c)}\]

    for all \(x, c > 0\). Here, \(\Gamma\) is the gamma function (scipy.special.gamma).

    loggamma takes c as a shape parameter for \(c\).

  • loglaplace Log-Laplace (Log Double Exponential) (help). The probability density function for loglaplace is:

    \[\begin{split}f(x, c) = \begin{cases}\frac{c}{2} x^{ c-1} &\text{for } 0 < x < 1\\ \frac{c}{2} x^{-c-1} &\text{for } x \ge 1 \end{cases}\end{split}\]

    for \(c > 0\).

    loglaplace takes c as a shape parameter for \(c\).

  • lognorm Log-Normal (help). The probability density function for lognorm is:

    \[f(x, s) = \frac{1}{s x \sqrt{2\pi}} \exp\left(-\frac{\log^2(x)}{2s^2}\right)\]

    for \(x > 0\), \(s > 0\).

    lognorm takes s as a shape parameter for \(s\).

  • loguniform Log-Uniform (help). The probability density function for this class is:

    \[f(x, a, b) = \frac{1}{x \log(b/a)}\]

    for \(a \le x \le b\), \(b > a > 0\). This class takes \(a\) and \(b\) as shape parameters.

  • lomax Lomax (Pareto of the second kind) (help). The probability density function for lomax is:

    \[f(x, c) = \frac{c}{(1+x)^{c+1}}\]

    for \(x \ge 0\), \(c > 0\).

    lomax takes c as a shape parameter for \(c\).

    lomax is a special case of pareto with loc=-1.0.

  • maxwell Maxwell (help). A special case of a chi distribution, with df=3, loc=0.0, and given scale = a, where a is the parameter used in the Mathworld description.

    The probability density function for maxwell is:

    \[f(x) = \sqrt{2/\pi}x^2 \exp(-x^2/2)\]

    for \(x >= 0\).

  • mielke Mielke’s Beta-Kappa (help). The probability density function for mielke is:

    \[f(x, k, s) = \frac{k x^{k-1}}{(1+x^s)^{1+k/s}}\]

    for \(x > 0\) and \(k, s > 0\). The distribution is sometimes called Dagum distribution. It was already defined in, called a Burr Type III distribution (burr with parameters c=s and d=k/s).

    mielke takes k and s as shape parameters.

  • moyal Moyal (help). The probability density function for moyal is:

    \[f(x) = \exp(-(x + \exp(-x))/2) / \sqrt{2\pi}\]

    for a real number \(x\).

  • nakagami Nakagami (help). The probability density function for nakagami is:

    \[f(x, \nu) = \frac{2 \nu^\nu}{\Gamma(\nu)} x^{2\nu-1} \exp(-\nu x^2)\]

    for \(x >= 0\), \(\nu > 0\).

    nakagami takes nu as a shape parameter for \(\nu\).

  • ncx2 Non-central chi-squared (help). The probability density function for ncx2 is:

    \[f(x, k, \lambda) = \frac{1}{2} \exp(-(\lambda+x)/2) (x/\lambda)^{(k-2)/4} I_{(k-2)/2}(\sqrt{\lambda x})\]

    for \(x >= 0\) and \(k, \lambda > 0\). \(k\) specifies the degrees of freedom (denoted df in the implementation) and \(\lambda\) is the non-centrality parameter (denoted nc in the implementation). \(I_\nu\) denotes the modified Bessel function of first order of degree \(\nu\) (scipy.special.iv).

    ncx2 takes df and nc as shape parameters.

  • ncf Non-central F (help). The probability density function for ncf is:

    \[\begin{split}f(x, n_1, n_2, \lambda) = \exp\left(\frac{\lambda}{2} + \lambda n_1 \frac{x}{2(n_1 x + n_2)} \right) n_1^{n_1/2} n_2^{n_2/2} x^{n_1/2 - 1} \\ (n_2 + n_1 x)^{-(n_1 + n_2)/2} \gamma(n_1/2) \gamma(1 + n_2/2) \\ \frac{L^{\frac{n_1}{2}-1}_{n_2/2} \left(-\lambda n_1 \frac{x}{2(n_1 x + n_2)}\right)} {B(n_1/2, n_2/2) \gamma\left(\frac{n_1 + n_2}{2}\right)}\end{split}\]

    for \(n_1, n_2 > 0\), \(\lambda \ge 0\). Here \(n_1\) is the degrees of freedom in the numerator, \(n_2\) the degrees of freedom in the denominator, \(\lambda\) the non-centrality parameter, \(\gamma\) is the logarithm of the Gamma function, \(L_n^k\) is a generalized Laguerre polynomial and \(B\) is the beta function.

    ncf takes df1, df2 and nc as shape parameters. If nc=0, the distribution becomes equivalent to the Fisher distribution.

  • nct Non-central Student’s T (help). If \(Y\) is a standard normal random variable and \(V\) is an independent chi-square random variable (chi2) with \(k\) degrees of freedom, then

    \[X = \frac{Y + c}{\sqrt{V/k}}\]

    has a non-central Student’s t distribution on the real line. The degrees of freedom parameter \(k\) (denoted df in the implementation) satisfies \(k > 0\) and the noncentrality parameter \(c\) (denoted nc in the implementation) is a real number.

  • norm Normal (Gaussian) (help). The probability density function for norm is:

    \[f(x) = \frac{\exp(-x^2/2)}{\sqrt{2\pi}}\]

    for a real number \(x\).

  • norminvgauss Normal Inverse Gaussian (help). The probability density function for norminvgauss is:

    \[f(x, a, b) = \frac{a \, K_1(a \sqrt{1 + x^2})}{\pi \sqrt{1 + x^2}} \, \exp(\sqrt{a^2 - b^2} + b x)\]

    where \(x\) is a real number, the parameter \(a\) is the tail heaviness and \(b\) is the asymmetry parameter satisfying \(a > 0\) and \(|b| <= a\). \(K_1\) is the modified Bessel function of second kind (scipy.special.k1).

  • pareto Pareto (help). The probability density function for pareto is:

    \[f(x, b) = \frac{b}{x^{b+1}}\]

    for \(x \ge 1\), \(b > 0\).

    pareto takes b as a shape parameter for \(b\).

  • pearson3 Pearson type III (help). The probability density function for pearson3 is:

    \[f(x, \kappa) = \frac{|\beta|}{\Gamma(\alpha)} (\beta (x - \zeta))^{\alpha - 1} \exp(-\beta (x - \zeta))\]

    where:

    \[ \begin{align}\begin{aligned}\beta = \frac{2}{\kappa}\\\alpha = \beta^2 = \frac{4}{\kappa^2}\\\zeta = -\frac{\alpha}{\beta} = -\beta\end{aligned}\end{align} \]

    \(\Gamma\) is the gamma function (scipy.special.gamma). Pass the skew \(\kappa\) into pearson3 as the shape parameter skew.

  • powerlaw Power-function (help). The probability density function for powerlaw is:

    \[f(x, a) = a x^{a-1}\]

    for \(0 \le x \le 1\), \(a > 0\).

    powerlaw takes a as a shape parameter for \(a\).

  • powerlognorm Power log normal (help). The probability density function for powerlognorm is:

    \[f(x, c, s) = \frac{c}{x s} \phi(\log(x)/s) (\Phi(-\log(x)/s))^{c-1}\]

    where \(\phi\) is the normal pdf, and \(\Phi\) is the normal cdf, and \(x > 0\), \(s, c > 0\).

    powerlognorm takes \(c\) and \(s\) as shape parameters.

  • powernorm Power normal (help). The probability density function for powernorm is:

    \[f(x, c) = c \phi(x) (\Phi(-x))^{c-1}\]

    where \(\phi\) is the normal pdf, and \(\Phi\) is the normal cdf, and \(x >= 0\), \(c > 0\).

    powernorm takes c as a shape parameter for \(c\).

  • rdist R-distribution (help). The probability density function for rdist is:

    \[f(x, c) = \frac{(1-x^2)^{c/2-1}}{B(1/2, c/2)}\]

    for \(-1 \le x \le 1\), \(c > 0\). rdist is also called the symmetric beta distribution: if B has a beta distribution with parameters (c/2, c/2), then X = 2*B - 1 follows a R-distribution with parameter c.

    rdist takes c as a shape parameter for \(c\).

    This distribution includes the following distribution kernels as special cases:

    c = 2:  uniform
    c = 3:  `semicircular`
    c = 4:  Epanechnikov (parabolic)
    c = 6:  quartic (biweight)
    c = 8:  triweight
    
  • rayleigh Rayleigh (help). The probability density function for rayleigh is:

    \[f(x) = x \exp(-x^2/2)\]

    for \(x \ge 0\).

    rayleigh is a special case of chi with df=2.

  • rice Rice (help). The probability density function for rice is:

    \[f(x, b) = x \exp(- \frac{x^2 + b^2}{2}) I_0(x b)\]

    for \(x >= 0\), \(b > 0\). \(I_0\) is the modified Bessel function of order zero (scipy.special.i0).

    rice takes b as a shape parameter for \(b\).

  • recipinvgauss Reciprocal Inverse Gaussian (help). The probability density function for recipinvgauss is:

    \[f(x, \mu) = \frac{1}{\sqrt{2\pi x}} \exp\left(\frac{-(1-\mu x)^2}{2\mu^2x}\right)\]

    for \(x \ge 0\).

    recipinvgauss takes mu as a shape parameter for \(\mu\).

  • semicircular Semicircular (help). The probability density function for semicircular is:

    \[f(x) = \frac{2}{\pi} \sqrt{1-x^2}\]

    for \(-1 \le x \le 1\).

    The distribution is a special case of rdist with c = 3.

  • skewcauchy Skew Cauchy (help). The probability density function for skewcauchy is:

    \[f(x) = \frac{1}{\pi \left(\frac{x^2}{\left(a\, \text{sign}(x) + 1 \right)^2} + 1 \right)}\]

    for a real number \(x\) and skewness parameter \(-1 < a < 1\).

    When \(a=0\), the distribution reduces to the usual Cauchy distribution.

  • skewnorm Skew normal (help). The pdf is:

    skewnorm.pdf(x, a) = 2 * norm.pdf(x) * norm.cdf(a*x)
    

    skewnorm takes a real number \(a\) as a skewness parameter. When a = 0 the distribution is identical to a normal distribution (norm).

  • studentized_range (help). The probability density function for studentized_range is:

    \[f(x; k, \nu) = \frac{k(k-1)\nu^{\nu/2}}{\Gamma(\nu/2) 2^{\nu/2-1}} \int_{0}^{\infty} \int_{-\infty}^{\infty} s^{\nu} e^{-\nu s^2/2} \phi(z) \phi(sx + z) [\Phi(sx + z) - \Phi(z)]^{k-2} \,dz \,ds\]

    for \(x ≥ 0\), \(k > 1\), and \(\nu > 0\).

    studentized_range takes k for \(k\) and df for \(\nu\) as shape parameters.

    When \(\nu\) exceeds 100,000, an asymptotic approximation (infinite degrees of freedom) is used to compute the cumulative distribution function.

  • t Student’s T (help). The probability density function for t is:

    \[f(x, \nu) = \frac{\Gamma((\nu+1)/2)} {\sqrt{\pi \nu} \Gamma(\nu/2)} (1+x^2/\nu)^{-(\nu+1)/2}\]

    where \(x\) is a real number and the degrees of freedom parameter \(\nu\) (denoted df in the implementation) satisfies \(\nu > 0\). \(\Gamma\) is the gamma function (scipy.special.gamma).

  • trapezoid Trapezoidal (help). The trapezoidal distribution can be represented with an up-sloping line from loc to (loc + c*scale), then constant to (loc + d*scale) and then downsloping from (loc + d*scale) to (loc+scale). This defines the trapezoid base from loc to (loc+scale) and the flat top from c to d proportional to the position along the base with 0 <= c <= d <= 1. When c=d, this is equivalent to triang with the same values for loc, scale and c.

    trapezoid takes \(c\) and \(d\) as shape parameters.

  • triang Triangular (help). The triangular distribution can be represented with an up-sloping line from loc to (loc + c*scale) and then downsloping for (loc + c*scale) to (loc + scale).

    triang takes c as a shape parameter for \(c\).

  • truncexpon Truncated Exponential (help). The probability density function for truncexpon is:

    \[f(x, b) = \frac{\exp(-x)}{1 - \exp(-b)}\]

    for \(0 <= x <= b\).

    truncexpon takes b as a shape parameter for \(b\).

  • truncnorm Truncated Normal (help). The standard form of this distribution is a standard normal truncated to the range [a, b] — notice that a and b are defined over the domain of the standard normal. To convert clip values for a specific mean and standard deviation, use:

    a, b = (myclip_a - my_mean) / my_std, (myclip_b - my_mean) / my_std
    

    truncnorm takes \(a\) and \(b\) as shape parameters.

  • tukeylambda Tukey-Lambda (help). A flexible distribution, able to represent and interpolate between the following distributions:

    • Cauchy (\(lambda = -1\))

    • logistic (\(lambda = 0\))

    • approx Normal (\(lambda = 0.14\))

    • uniform from -1 to 1 (\(lambda = 1\))

    tukeylambda takes a real number \(lambda\) (denoted lam in the implementation) as a shape parameter.

  • uniform Uniform (help). a uniform continuous random variable

  • vonmises Von-Mises (Circular) (help). The probability density function for vonmises and vonmises_line is:

    \[f(x, \kappa) = \frac{ \exp(\kappa \cos(x)) }{ 2 \pi I_0(\kappa) }\]

    for \(-\pi \le x \le \pi\), \(\kappa > 0\). \(I_0\) is the modified Bessel function of order zero (scipy.special.i0).

    vonmises is a circular distribution which does not restrict the distribution to a fixed interval. Currently, there is no circular distribution framework in scipy. The cdf is implemented such that cdf(x + 2*np.pi) == cdf(x) + 1.

    vonmises_line is the same distribution, defined on \([-\pi, \pi]\) on the real line. This is a regular (i.e. non-circular) distribution.

    vonmises and vonmises_line take kappa as a shape parameter.

  • vonmises_line (help). The probability density function for vonmises and vonmises_line is:

    \[f(x, \kappa) = \frac{ \exp(\kappa \cos(x)) }{ 2 \pi I_0(\kappa) }\]

    for \(-\pi \le x \le \pi\), \(\kappa > 0\). \(I_0\) is the modified Bessel function of order zero (scipy.special.i0).

    vonmises is a circular distribution which does not restrict the distribution to a fixed interval. Currently, there is no circular distribution framework in scipy. The cdf is implemented such that cdf(x + 2*np.pi) == cdf(x) + 1.

    vonmises_line is the same distribution, defined on \([-\pi, \pi]\) on the real line. This is a regular (i.e. non-circular) distribution.

    vonmises and vonmises_line take kappa as a shape parameter.

  • wald Wald (help). The probability density function for wald is:

    \[f(x) = \frac{1}{\sqrt{2\pi x^3}} \exp(- \frac{ (x-1)^2 }{ 2x })\]

    for \(x >= 0\).

    wald is a special case of invgauss with mu=1.

  • weibull_min (help). The probability density function for weibull_min is:

    \[f(x, c) = c x^{c-1} \exp(-x^c)\]

    for \(x > 0\), \(c > 0\).

    weibull_min takes c as a shape parameter for \(c\). (named \(k\) in Wikipedia article and \(a\) in numpy.random.weibull). Special shape values are \(c=1\) and \(c=2\) where Weibull distribution reduces to the expon and rayleigh distributions respectively.

  • weibull_max (help). The probability density function for weibull_max is:

    \[f(x, c) = c (-x)^{c-1} \exp(-(-x)^c)\]

    for \(x < 0\), \(c > 0\).

    weibull_max takes c as a shape parameter for \(c\).

  • wrapcauchy Wrapped Cauchy (help). The probability density function for wrapcauchy is:

    \[f(x, c) = \frac{1-c^2}{2\pi (1+c^2 - 2c \cos(x))}\]

    for \(0 \le x \le 2\pi\), \(0 < c < 1\).

    wrapcauchy takes c as a shape parameter for \(c\).