![]() |
Home | Libraries | People | FAQ | More |
#include <boost/math/distributions/generalized_extreme_value.hpp>
template <class RealType = double, class Policy = policies::policy<> > class generalized_extreme_value_distribution; typedef generalized_extreme_value_distribution<> generalized_extreme_value; template <class RealType, class Policy> class generalized_extreme_value_distribution { public: typedef RealType value_type; generalized_extreme_value_distribution(RealType location = 0, RealType scale = 1, RealType shape = 0); RealType location()const; RealType scale()const; RealType shape()const; };
The generalized extreme value distribution is the family of limit distributions of the normalized maxima of independent, identically distributed random variables. With location μ, scale σ and shape ξ, its CDF is
F(x) = e-t(x), t(x) = (1 + ξ(x - μ)/σ)-1/ξ
on the support where 1 + ξ(x - μ)/σ > 0, and its PDF is
f(x) = t(x)ξ+1 e-t(x) / σ
The shape selects the type:
Note that the sign convention for the shape varies: SciPy's genextreme, for example, takes c = -ξ.
generalized_extreme_value_distribution(RealType location = 0, RealType scale = 1, RealType shape = 0);
Constructs a generalized extreme value distribution with the specified location, scale and shape.
Requires that location and shape are finite and that scale is finite and > 0, otherwise calls domain_error.
RealType location()const; RealType scale()const; RealType shape()const;
Return the parameters of the distribution.
All the usual non-member accessor functions that are generic to all distributions are supported: Cumulative Distribution Function, Probability Density Function, Quantile, Hazard Function, Cumulative Hazard Function, __logcdf, __logpdf, mean, median, mode, variance, standard deviation, skewness, kurtosis, kurtosis_excess, range and support.
The domain of the random variable is [-∞, +∞]: outside the support the PDF
is zero and the CDF is 0 or 1. support
returns the bounded end for ξ ≠ 0.
The mean is infinite for ξ ≥ 1 and the variance for ξ ≥ 1/2, and both return +∞ there. The skewness is undefined for ξ ≥ 1/3 and the kurtosis for ξ ≥ 1/4, where they call domain_error. The quantile at the unbounded ends calls overflow_error, as does the PDF at the upper end point when ξ < -1, where the density is infinite.
logpdf, logcdf
and the log of the complement of the CDF are specialized for accuracy deep
in the tails.
Against references computed with mpmath at the double values of the arguments, the PDF, CDF, their complements and logs, and the quantiles are within a few ulps, except where the function is itself ill-conditioned: deep in the tails of the CDF, where e-t magnifies the rounding of (x - μ)/σ (up to about 30 ulps), and where the quantile is close to zero and μ + σ q cancels. The mean, variance, mode, median and entropy are within a few ulps. Skewness and kurtosis are accurate to an absolute error of a few tens of epsilon for |ξ| < 1/4, and of a few hundred for larger |ξ|, where they are third and fourth differences of logΓ(1 - kξ); both change sign (the skewness near ξ = -0.28, the excess kurtosis near ξ = -0.15), so their relative error is unbounded there.
In the following table μ is the location, σ the scale, ξ the shape, z = (x - μ)/σ, p the probability and q = 1 - p; gk = Γ(1 - kξ).
|
Function |
Implementation Notes |
|---|---|
|
|
exp(-(1 + ξ)L - t) / σ, where L = -log t = log1p(ξz)/ξ, and t = e-L. |
|
logpdf |
-log σ - (1 + ξ)L - t |
|
cdf |
exp(-t) |
|
logcdf |
-t |
|
cdf complement |
-expm1(-t) |
|
log of the cdf complement |
log(-expm1(-t)) for t < log 2, otherwise log1p(-e-t) |
|
quantile |
μ + σ expm1(-ξ log y)/ξ with y = -log p, or μ + σ(y-ξ - 1)/ξ when |ξ log y| > 1. |
|
quantile from the complement |
As the quantile, with y = -log1p(-q). |
|
mean |
μ + σ tgamma1pm1(-ξ)/ξ |
|
variance |
(σg1/ξ)2 expm1(A2), with Ak = log gk - k log g1 |
|
skewness |
sign(ξ) (g3 - 3g1g2 + 2g13) / (g2 - g12)3/2, written in terms of the Ak so that the cancellation at small ξ is exact: the combinations of the Ak are summed from the Taylor series logΓ(1 - z) = γz + ∑ ζ(j) zj/j, in which their low orders vanish identically, while the series converges quickly. |
|
kurtosis excess |
(g4 - 4g1g3 + 6g12g2 - 3g14) / (g2 - g12)2 - 3, as for the skewness. |
|
mode |
μ + σ((1 + ξ)-ξ - 1)/ξ, or the upper end point μ - σ/ξ for ξ ≤ -1. |
|
median |
μ + σ((log 2)-ξ - 1)/ξ |
|
entropy |
log σ + γ(1 + ξ) + 1 |
At ξ = 0, and for |ξ| below machine epsilon in the moments, the Gumbel formulas are used.