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’sbeta(a, b)). - Binomial
- The binomial distribution
B(n, p)(SciPy’sbinom(n, p)). - Cauchy
- The Cauchy distribution (SciPy’s
cauchy(loc, scale)). - ChiSquared
- The chi-squared distribution with
kdegrees of freedom (SciPy’schi2(df=k)). - Exponential
- The exponential distribution with rate λ (SciPy’s
expon(scale=1/λ)). - FDist
- The F distribution with
d₁andd₂degrees of freedom (SciPy’sf(dfn, dfd)). - Gamma
- The gamma distribution with shape
kand scaleθ(SciPy’sgamma(a=k, scale=θ)). - Generalized
Extreme Value - The generalised extreme value distribution with shape
ξ, location and scale, in the statistics convention:ξ > 0is heavy-tailed (Fréchet),ξ < 0bounded above (Weibull). SciPy’sgenextreme(c)usesc = −ξ. - Geometric
- The geometric distribution of the number of trials up to the first success,
k ≥ 1(SciPy’sgeom(p)). - Gumbel
- The Gumbel distribution of maxima (SciPy’s
gumbel_r(loc=μ, scale=β)). - Hypergeometric
- The hypergeometric distribution of the successes in
drawsdraws without replacement from a population oftotalitems of whichsuccessesare successes (SciPy’shypergeom(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’slognorm(s=σ, scale=e^μ)). - Logistic
- The logistic distribution (SciPy’s
logistic(loc=μ, scale=s)). - Negative
Binomial - The negative binomial distribution of the number of failures before the
r-th success (SciPy’snbinom(n=r, p));rneed not be an integer. - Normal
- The normal distribution N(μ, σ²) (SciPy’s
norm(loc=μ, scale=σ)). - Pareto
- The Pareto distribution with shape
αand scalex_m(SciPy’spareto(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’srice(b = ν/σ, scale = σ)):f(x) = x/σ² exp(−(x² + ν²)/(2σ²)) I₀(xν/σ²). Withν = 0it is the Rayleigh distribution; forν ≫ σit approachesN(ν, σ²).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. - Skew
Normal - The skew-normal distribution with shape
α(SciPy’sskewnorm(a=α, loc, scale)): density2 φ(z) Φ(αz) / scale. - StudentT
- Student’s t distribution with
νdegrees of freedom, location and scale (SciPy’st(df=ν, loc, scale)). - Truncated
Normal - The normal distribution
N(μ, σ²)truncated to[a, b](SciPy’struncnorm((a−μ)/σ, (b−μ)/σ, loc=μ, scale=σ)). - Uniform
- The continuous uniform distribution on
[a, b](SciPy’suniform(loc=a, scale=b−a)). - VonMises
- The von Mises distribution on the circle,
f(x) ∝ e^{κ cos(x − μ)}on[μ − π, μ + π](SciPy’svonmises(kappa=κ, loc=μ)). - Weibull
- The Weibull distribution with shape
kand scaleλ(SciPy’sweibull_min(c=k, scale=λ)).
Traits§
- Continuous
Distribution - A continuous probability distribution on the real line.
- Discrete
Distribution - 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 ofdiston its support (order 5, resolution 1e-12), withppf,cdf,rvsandqrvs_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 ≥ 6and the asymptotic series.