mixle.stats.univariate.continuous.generalized_extreme_value module¶
Generalized Extreme Value distribution (GEV): the limit law of block maxima.
By the Fisher-Tippett-Gnedenko theorem the normalized maximum of a large block of iid observations
converges to a GEV, the standard model for extremes (flood levels, wind speeds, record losses). With
location mu, scale sigma > 0 and shape xi (the EVT sign convention; scipy’s
genextreme uses c = -xi), for z = (x - mu)/sigma:
log f = -log sigma - (1/xi + 1) log s - s ** (-1/xi), s = 1 + xi z > 0 (xi != 0), log f = -log sigma - z - exp(-z) (xi == 0, Gumbel).
xi > 0 is the heavy-tailed Frechet type (support x >= mu - sigma/xi), xi = 0 the Gumbel
type (all reals), xi < 0 the bounded Weibull type (x <= mu - sigma/xi). All three parameters
are fit by method of moments: the shape is solved from the (monotone) skewness-vs-xi relation,
then scale from the variance and location from the mean.
Reference: Coles, An Introduction to Statistical Modeling of Extreme Values (Springer, 2001).
- class GeneralizedExtremeValueDistribution(loc, scale, shape, name=None, keys=None)[source]
Bases:
SequenceEncodableProbabilityDistributionGeneralized Extreme Value distribution with location
loc, scale> 0and shapexi.- density(x)[source]
Return the probability density at a single observation.
- log_density(x)[source]
Return the log-density at a single observation (
-infoutside the support).
- seq_log_density(x)[source]
Return vectorized log-density values for sequence-encoded observations.
- classmethod compute_capabilities()[source]
Describe backend support for generated GEV kernels.
- classmethod compute_declaration()[source]
Return the structured compute declaration for GEV distributions.
- static backend_legacy_sufficient_statistics(x, params, engine)[source]
Per-row GEV moment sums in accumulator order
(sum, sum2, sum3, count).
- static backend_log_density_from_params(x, loc, scale, shape, engine)[source]
Engine-neutral GEV log-density; the
|xi| < tolGumbel limit is selected per element.s^{-1/xi}is computed asexp(-log(s)/xi)so the whole expression stays on engine ops.
- backend_seq_log_density(x, engine)[source]
Engine-neutral vectorized log-density for encoded data.
- classmethod backend_stacked_params(dists, engine)[source]
Stacked GEV parameters for a homogeneous mixture kernel.
- classmethod backend_stacked_log_density(x, params, engine)[source]
Return an
(n, k)matrix of GEV log densities.
- classmethod backend_stacked_sufficient_statistics(x, weights, params, engine)[source]
Stacked GEV moment sums
(sum, sum2, sum3, count)using engine-resident arrays.
- cdf(x)[source]
Cumulative distribution function
P(X <= x)(exact).
- mean()[source]
Mean: loc + scale*(Gamma(1-xi)-1)/xi (loc+scale*euler_gamma at xi=0); inf for xi>=1.
- Return type:
- variance()[source]
Variance: scale^2 (Gamma(1-2xi)-Gamma(1-xi)^2)/xi^2 (scale^2 pi^2/6 at xi=0); inf for xi>=1/2.
- Return type:
- sampler(seed=None)[source]
Return a sampler for drawing observations from this distribution.
- Parameters:
seed (int | None)
- Return type:
GeneralizedExtremeValueSampler
- estimator(pseudo_count=None)[source]
Return a method-of-moments estimator for
loc,scaleandshape.- Parameters:
pseudo_count (float | None)
- Return type:
GeneralizedExtremeValueEstimator
- dist_to_encoder()[source]
Return the data encoder used by this distribution for vectorized methods.
- Return type:
GeneralizedExtremeValueDataEncoder
- class GeneralizedExtremeValueSampler(dist, seed=None)[source]
Bases:
DistributionSamplerDraw iid GEV observations by inverse-CDF transform.
- Parameters:
dist (GeneralizedExtremeValueDistribution)
seed (int | None)
- class GeneralizedExtremeValueAccumulator(name=None, keys=None)[source]
Bases:
SequenceEncodableStatisticAccumulatorAccumulate weighted first three moments for GEV estimation.
- update(x, weight, estimate)[source]
Accumulate weighted first three raw moments for one observation.
- initialize(x, weight, rng)[source]
Initialize statistics from one observation.
- Parameters:
x (float)
weight (float)
rng (RandomState | None)
- Return type:
None
- seq_update(x, weights, estimate)[source]
Accumulate weighted first three raw moments from encoded data.
- seq_initialize(x, weights, rng)[source]
Initialize statistics from encoded observations.
- Parameters:
x (ndarray)
weights (ndarray)
rng (RandomState | None)
- Return type:
None
- combine(suff_stat)[source]
Merge another GEV sufficient-statistic tuple.
- value()[source]
Return raw moment sums and observation count.
- from_value(x)[source]
Replace accumulator contents from a sufficient-statistic tuple.
- key_merge(stats_dict)[source]
Merge keyed statistics into
stats_dictwhen keys are configured.
- key_replace(stats_dict)[source]
Replace this accumulator from keyed statistics when available.
- acc_to_encoder()[source]
Return the encoder used by this accumulator.
- Return type:
GeneralizedExtremeValueDataEncoder
- class GeneralizedExtremeValueAccumulatorFactory(name=None, keys=None)[source]
Bases:
StatisticAccumulatorFactoryFactory for GeneralizedExtremeValueAccumulator.
- make()[source]
Create a fresh GEV accumulator.
- Return type:
GeneralizedExtremeValueAccumulator
- class GeneralizedExtremeValueEstimator(pseudo_count=None, min_scale=1.0e-12, xi_max=1.0 / 3.0 - 1.0e-4, xi_min=-1.0, name=None, keys=None)[source]
Bases:
ParameterEstimatorMethod-of-moments estimator for GEV location, scale and shape.
- Parameters:
- accumulator_factory()[source]
Return an accumulator factory for GEV raw-moment statistics.
- Return type:
GeneralizedExtremeValueAccumulatorFactory