Skip to main content

Module distributions

Module distributions 

Source
Expand description

Probability distributions as objects, following scipy.stats: each continuous distribution provides its density, distribution and survival functions, quantiles, moments, sampling and maximum-likelihood fitting through ContinuousDistribution and Fit; the discrete ones through DiscreteDistribution.

Quantiles have closed forms where they exist; otherwise the distribution function is inverted by Brent’s method. Fitting uses the closed-form estimators or score equations where they exist (normal, exponential, log-normal, gamma, beta, Weibull, Gumbel, Laplace, Pareto, Rayleigh, von Mises, Poisson, negative binomial…) and Nelder-Mead on the log-likelihood otherwise.

See the book entry Probability distributions.

Structs§

Beta
The beta distribution on [0, 1] (SciPy’s beta(a, b)).
Binomial
The binomial distribution B(n, p) (SciPy’s binom(n, p)).
Cauchy
The Cauchy distribution (SciPy’s cauchy(loc, scale)).
ChiSquared
The chi-squared distribution with k degrees of freedom (SciPy’s chi2(df=k)).
Exponential
The exponential distribution with rate λ (SciPy’s expon(scale=1/λ)).
FDist
The F distribution with d₁ and d₂ degrees of freedom (SciPy’s f(dfn, dfd)).
Gamma
The gamma distribution with shape k and scale θ (SciPy’s gamma(a=k, scale=θ)).
GeneralizedExtremeValue
The generalised extreme value distribution with shape ξ, location and scale, in the statistics convention: ξ > 0 is heavy-tailed (Fréchet), ξ < 0 bounded above (Weibull). SciPy’s genextreme(c) uses c = −ξ.
Geometric
The geometric distribution of the number of trials up to the first success, k ≥ 1 (SciPy’s geom(p)).
Gumbel
The Gumbel distribution of maxima (SciPy’s gumbel_r(loc=μ, scale=β)).
Hypergeometric
The hypergeometric distribution of the successes in draws draws without replacement from a population of total items of which successes are successes (SciPy’s hypergeom(M=total, n=successes, N=draws)).
Laplace
The Laplace (double exponential) distribution (SciPy’s laplace(loc=μ, scale=b)).
LogNormal
The log-normal distribution: ln X ~ N(μ, σ²) (SciPy’s lognorm(s=σ, scale=e^μ)).
Logistic
The logistic distribution (SciPy’s logistic(loc=μ, scale=s)).
NegativeBinomial
The negative binomial distribution of the number of failures before the r-th success (SciPy’s nbinom(n=r, p)); r need not be an integer.
Normal
The normal distribution N(μ, σ²) (SciPy’s norm(loc=μ, scale=σ)).
Pareto
The Pareto distribution with shape α and scale x_m (SciPy’s pareto(b=α, scale=x_m)).
Poisson
The Poisson distribution (SciPy’s poisson(mu=λ)).
Rayleigh
The Rayleigh distribution (SciPy’s rayleigh(scale=σ)).
Rice
The Rice distribution of the length of a two-dimensional normal vector with mean length ν and standard deviation σ per component (SciPy’s rice(b = ν/σ, scale = σ)): f(x) = x/σ² exp(−(x² + ν²)/(2σ²)) I₀(xν/σ²). With ν = 0 it is the Rayleigh distribution; for ν ≫ σ it approaches N(ν, σ²). X²/σ² is non-central χ² with 2 degrees of freedom and non-centrality (ν/σ)², which gives the distribution function as a Poisson mixture of regularised incomplete gamma functions.
SkewNormal
The skew-normal distribution with shape α (SciPy’s skewnorm(a=α, loc, scale)): density 2 φ(z) Φ(αz) / scale.
StudentT
Student’s t distribution with ν degrees of freedom, location and scale (SciPy’s t(df=ν, loc, scale)).
TruncatedNormal
The normal distribution N(μ, σ²) truncated to [a, b] (SciPy’s truncnorm((a−μ)/σ, (b−μ)/σ, loc=μ, scale=σ)).
Uniform
The continuous uniform distribution on [a, b] (SciPy’s uniform(loc=a, scale=b−a)).
VonMises
The von Mises distribution on the circle, f(x) ∝ e^{κ cos(x − μ)} on [μ − π, μ + π] (SciPy’s vonmises(kappa=κ, loc=μ)).
Weibull
The Weibull distribution with shape k and scale λ (SciPy’s weibull_min(c=k, scale=λ)).

Traits§

ContinuousDistribution
A continuous probability distribution on the real line.
DiscreteDistribution
A discrete distribution on the integers.
Fit
Maximum-likelihood estimation of a distribution’s parameters (SciPy’s fit, with the location fixed where the distribution has no location parameter here).

Functions§

fast_generator_inversion
A generator by fast numerical inversion of a distribution (SciPy’s FastGeneratorInversion): polynomial inversion of the density of dist on its support (order 5, resolution 1e-12), with ppf, cdf, rvs and qrvs_sobol. The centre, where the density is positive, is the median.
owens_t
Owen’s T function T(h, a) = (1/2π) ∫₀ᵃ e^{−h²(1+x²)/2} / (1 + x²) dx.
trigamma
The trigamma function ψ’(x), by recurrence to x ≥ 6 and the asymptotic series.