Distributions¶
NumPyro-native extreme value distributions. Every class subclasses
numpyro.distributions.Distribution, so it plugs directly into MCMC / SVI /
Predictive and is differentiable end to end. Beyond sample / log_prob,
each carries the EVT toolkit: cdf, icdf, survival_function, mean,
variance, entropy, and return_level.
All of them delegate their math to the primitives — reach for those directly if you want a density without a distribution object.
Generalized Extreme Value¶
The distribution for block maxima (annual temperature maxima, seasonal peak discharge). The concentration \(\xi\) selects the tail type continuously, so inference can learn which regime the data is in instead of you committing up front — this is the default choice unless you have reason to fix \(\xi\).
NumPyro-compatible extreme value distributions.
GeneralizedExtremeValueDistribution(loc: ArrayLike = 0.0, scale: ArrayLike = 1.0, concentration: ArrayLike | None = None, shape: ArrayLike | None = None, validate_args: bool | None = None)
¶
Bases: Distribution
Generalized Extreme Value Distribution (GEVD) for NumPyro.
The GEVD is a family of continuous probability distributions developed within extreme value theory. It encompasses three types of extreme value distributions:
- Type I (Gumbel): ξ = 0, exponential tails
- Type II (Fréchet): ξ > 0, heavy polynomial tails
- Type III (Weibull): ξ < 0, bounded upper tail
Probability Density Function:
For ξ ≠ 0: f(x) = (1/σ) * t(x)^(-(1/ξ + 1)) * exp(-t(x)^(-1/ξ)) where t(x) = 1 + ξ(x - μ)/σ
For ξ = 0 (Gumbel limit): f(x) = (1/σ) * exp(-(x - μ)/σ) * exp(-exp(-(x - μ)/σ))
Cumulative Distribution Function:
For ξ ≠ 0: F(x) = exp(-t(x)^(-1/ξ)) where t(x) = 1 + ξ(x - μ)/σ
For ξ = 0: F(x) = exp(-exp(-(x - μ)/σ))
Support:
- ξ > 0: x ≥ μ - σ/ξ (lower bounded)
- ξ = 0: x ∈ ℝ (unbounded)
- ξ < 0: x ≤ μ - σ/ξ (upper bounded)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loc
|
float
|
Location parameter μ ∈ ℝ |
0.0
|
scale
|
float
|
Scale parameter σ > 0 |
1.0
|
shape
|
float
|
Shape parameter ξ ∈ ℝ |
None
|
Examples:
>>> import jax
>>> import jax.numpy as jnp
>>>
>>> # Create GEVD instances for each type
>>> gumbel = GeneralizedExtremeValueDistribution(loc=0, scale=1, shape=0)
>>> frechet = GeneralizedExtremeValueDistribution(loc=0, scale=1, shape=0.2)
>>> weibull = GeneralizedExtremeValueDistribution(loc=0, scale=1, shape=-0.2)
>>>
>>> # Sample and evaluate
>>> key = jax.random.PRNGKey(42)
>>> samples = frechet.sample(key, sample_shape=(1000,))
>>> log_probs = frechet.log_prob(samples)
Initialize the Generalized Extreme Value Distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loc
|
ArrayLike
|
Location parameter μ (real number) |
0.0
|
scale
|
ArrayLike
|
Scale parameter σ (positive real number) |
1.0
|
concentration
|
ArrayLike | None
|
Shape parameter ξ (real number) |
None
|
shape
|
ArrayLike | None
|
Deprecated backward-compatible alias for |
None
|
validate_args
|
bool | None
|
Whether to validate input arguments |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If scale <= 0 |
Source code in src/xtremax/distributions/gevd.py
support: constraints.Constraint
property
¶
Return the support of the distribution.
Returns:
| Type | Description |
|---|---|
Constraint
|
Constraint object reflecting the shape-dependent support: |
Constraint
|
|
Constraint
|
|
Constraint
|
|
The constraint kind is dispatched on the statically known sign of
the concentration so that biject_to(support) returns a bijector
that genuinely handles the half-unbounded geometry — the previous
interval(lo, hi) construction mapped to Sigmoid ∘ Affine
which yields inf/nan when a bound is infinite, breaking every
NUTS/SVI model that used this distribution as a latent site.
When the concentration is traced (inside jit/inference) or a
mixed-sign batch, the sign is not statically known and the support
falls back to constraints.real: membership then accepts points
outside the true parameter-dependent support, but log_prob
returns -inf there, so inference remains correct (init simply
rejects such draws).
mean: jnp.ndarray
property
¶
Mean. Thin wrapper for :func:~xtremax.primitives.gev.gev_mean.
mode: jnp.ndarray
property
¶
Compute the mode of the distribution.
For ξ ≠ 0: mode = μ + (σ/ξ) * ((1+ξ)^(-ξ) - 1)
This interior stationary point only exists for ξ > -1. For ξ ≤ -1 (Weibull branch), the density increases all the way to the finite upper endpoint, so the mode is the upper bound itself.
For ξ = 0: mode = μ
Returns:
| Type | Description |
|---|---|
ndarray
|
Mode of the distribution |
variance: jnp.ndarray
property
¶
Compute the variance of the distribution.
The variance exists when ξ < 1/2:
For ξ ≠ 0, ξ < 1/2: Var[X] = (σ²/ξ²) * (Γ(1-2ξ) - Γ²(1-ξ))
For ξ = 0: Var[X] = σ² * π²/6
Thin wrapper for :func:~xtremax.primitives._moments.gev_variance,
which evaluates the Γ-difference through a cancellation-free
reduced form — the direct subtraction above loses every significant
digit for small ξ.
Returns:
| Type | Description |
|---|---|
ndarray
|
Variance, or +∞ when it doesn't exist (ξ ≥ 1/2) |
sample(key: jnp.ndarray, sample_shape: tuple = (), *, shape: tuple | None = None) -> jnp.ndarray
¶
Generate samples from the GEVD using inverse transform sampling.
The sampling uses the quantile function (inverse CDF):
For ξ ≠ 0: Q(p) = μ + (σ/ξ) * ((-ln(p))^(-ξ) - 1)
For ξ = 0: Q(p) = μ - σ * ln(-ln(p))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
ndarray
|
JAX random key for sampling |
required |
sample_shape
|
tuple
|
Shape of samples to generate |
()
|
shape
|
tuple | None
|
Keyword-only alias for |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of samples from the GEVD |
Source code in src/xtremax/distributions/gevd.py
log_prob(value: jnp.ndarray) -> jnp.ndarray
¶
Log PDF. Thin wrapper for :func:~xtremax.primitives.gev.gev_log_prob.
cdf(value: jnp.ndarray) -> jnp.ndarray
¶
CDF. Thin wrapper for :func:~xtremax.primitives.gev.gev_cdf.
icdf(q: jnp.ndarray) -> jnp.ndarray
¶
upper_bound() -> jnp.ndarray
¶
Compute the upper bound of the support.
Returns:
| Type | Description |
|---|---|
ndarray
|
Upper bound: μ - σ/ξ for ξ < 0, +∞ otherwise |
Source code in src/xtremax/distributions/gevd.py
lower_bound() -> jnp.ndarray
¶
Compute the lower bound of the support.
Returns:
| Type | Description |
|---|---|
ndarray
|
Lower bound: μ - σ/ξ for ξ > 0, -∞ otherwise |
Source code in src/xtremax/distributions/gevd.py
covariance() -> jnp.ndarray
¶
Marginal variance broadcast to the batch shape.
Structural seam for pipekit_cycle.ObservationNoise (which
requires covariance() and sample(key, shape)): together
with the existing :meth:sample, this lets the distribution act
as a non-Gaussian observation-error model in data-assimilation
experiments — without xtremax importing pipekit (see
docs/interop.md). The observation errors are treated as
independent per batch element, so the "covariance" is the
marginal variance vector rather than a dense matrix; consuming
analysis steps interpret it as a diagonal.
Returns:
| Type | Description |
|---|---|
ndarray
|
Variance broadcast to |
ndarray
|
variance does not exist, i.e. ξ >= 1/2). |
Source code in src/xtremax/distributions/gevd.py
kurtosis() -> jnp.ndarray
¶
Compute the excess kurtosis of the distribution.
Excess kurtosis exists when ξ < 1/4. The formula involves fourth-order moments and gamma functions:
κ = μ₄/σ⁴ - 3
where μ₄ is the fourth central moment.
Thin wrapper for
:func:~xtremax.primitives._moments.gev_excess_kurtosis, which
evaluates the fourth-moment gamma combination through a
cancellation-free reduced form (it loses two leading orders in
the naive one) and reduces to the Gumbel value 12/5 at ξ = 0.
Returns:
| Type | Description |
|---|---|
ndarray
|
Excess kurtosis, or NaN when it doesn't exist (ξ ≥ 1/4) |
Source code in src/xtremax/distributions/gevd.py
skew() -> jnp.ndarray
¶
Compute the skewness of the distribution.
Skewness exists when ξ < 1/3:
For Gumbel (ξ = 0): skew ≈ 1.1396 For general GEVD: involves third-order moments and gamma functions
Thin wrapper for :func:~xtremax.primitives._moments.gev_skewness,
which evaluates the third-moment gamma combination through a
cancellation-free reduced form. The reduced ratio carries the sign
of ξ on its own, so no explicit sign(ξ) factor is needed.
Returns:
| Type | Description |
|---|---|
ndarray
|
Skewness, or NaN when it doesn't exist (ξ ≥ 1/3) |
Source code in src/xtremax/distributions/gevd.py
entropy() -> jnp.ndarray
¶
Differential entropy of the GEV distribution (in nats).
For any :math:\xi (including the Gumbel limit),
.. math:: H = \log\sigma + 1 + \gamma(1 + \xi)
where :math:\gamma is the Euler–Mascheroni constant. At
:math:\xi = 0 this correctly reduces to :math:\log\sigma + 1 + \gamma
(the Gumbel entropy), so no separate branch is needed.
Source code in src/xtremax/distributions/gevd.py
survival_function(value: jnp.ndarray) -> jnp.ndarray
¶
Compute the survival function S(x) = 1 - F(x).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ndarray
|
Points at which to evaluate the survival function |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Survival probabilities |
Source code in src/xtremax/distributions/gevd.py
log_survival_function(value: jnp.ndarray) -> jnp.ndarray
¶
Compute the log survival function log S(x) = log( 1 - F(x) ).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ndarray
|
Points at which to evaluate the survival function |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Survival probabilities |
Source code in src/xtremax/distributions/gevd.py
hazard_rate(value: jnp.ndarray) -> jnp.ndarray
¶
Compute the hazard rate h(x) = f(x) / S(x).
The hazard rate represents the instantaneous rate of failure given survival up to time x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ndarray
|
Points at which to evaluate the hazard rate |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Hazard rate values |
Source code in src/xtremax/distributions/gevd.py
cumulative_hazard_rate(value: jnp.ndarray) -> jnp.ndarray
¶
Compute the cumulative hazard rate Λ(x) = -log(S(x)).
This represents the accumulated hazard up to time x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ndarray
|
Points at which to evaluate the cumulative hazard rate |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Cumulative hazard rate values |
Source code in src/xtremax/distributions/gevd.py
return_level(return_period: float | jnp.ndarray) -> jnp.ndarray
¶
Return level. Thin wrapper for gev_return_level.
tail_index() -> jnp.ndarray
¶
Compute the tail index α = 1/ξ for ξ > 0.
For Fréchet distributions (ξ > 0), the tail follows a power law: P(X > x) ~ x^(-1/ξ) as x → ∞
Returns:
| Type | Description |
|---|---|
ndarray
|
Tail index (1/ξ for ξ > 0, ∞ for ξ ≤ 0) |
Source code in src/xtremax/distributions/gevd.py
exceedance_probability(threshold: jnp.ndarray) -> jnp.ndarray
¶
Compute probability of exceeding a threshold: P(X > threshold).
This is equivalent to the survival function at the threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
threshold
|
ndarray
|
Threshold value |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Exceedance probabilities |
Source code in src/xtremax/distributions/gevd.py
conditional_excess_mean(threshold: jnp.ndarray) -> jnp.ndarray
¶
Mean excess :math:E[X - u \mid X > u] for the GEV distribution.
Computed via quantile-space quadrature:
.. math:: E[X \mid X > u] = \frac{\int_{F(u)}^{1} F^{-1}(p)\, dp}{1 - F(u)}
using a per-threshold trapezoidal rule on a grid from
:math:F(u) to :math:1 - \epsilon. This is exact up to
quadrature error across all three GEV branches (Gumbel,
Fréchet, Weibull).
The previous implementation used the GPD linear form
:math:(\sigma + \xi(u - \mu)) / (1 - \xi), which is the
Pickands–Balkema–de Haan POT limit — correct only as
:math:u \to upper endpoint, and notably returning a constant
:math:\sigma for all :math:u when :math:\xi = 0 even
though the true Gumbel mean excess depends on :math:u.
Returns NaN where the mean does not exist (:math:\xi \ge 1).
Source code in src/xtremax/distributions/gevd.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 | |
reliability_function(time: jnp.ndarray) -> jnp.ndarray
¶
Compute the reliability function R(t) = P(X > t).
This is equivalent to the survival function but emphasizes the reliability engineering interpretation for Weibull Type III.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Time points for reliability evaluation |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Reliability values (probability of surviving past time t) |
Source code in src/xtremax/distributions/gevd.py
mean_residual_life(time: jnp.ndarray) -> jnp.ndarray
¶
Compute the mean residual life function: E[X - t | X > t].
For reliability applications, this represents the expected additional lifetime given survival to time t.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Current time/age |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Mean residual life values |
Source code in src/xtremax/distributions/gevd.py
percentile_residual_life(time: jnp.ndarray, percentile: float) -> jnp.ndarray
¶
Compute percentile residual life: (Q(p|X>t) - t).
This gives the additional time until the p-th percentile failure, conditional on survival to time t.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Current time/age |
required |
percentile
|
float
|
Percentile level (0 < percentile < 1) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Percentile residual life values |
Source code in src/xtremax/distributions/gevd.py
expand(batch_shape: tuple[int, ...]) -> dist.Distribution
¶
Expand to batch_shape by reconstructing via __init__.
Going through the constructor (rather than an ExpandedDistribution
wrapper) keeps every EVT method available on the returned instance.
Source code in src/xtremax/distributions/gevd.py
Ragged records: masking the likelihood¶
Station networks rarely share a calendar. Annual maxima over \(S\) stations and \(T\) years arrive as an \((S, T)\) grid with gaps where a station had no record that year, and the likelihood should only see the observed station-years.
Use NumPyro's masking distribution — fill the gaps with any in-support value (the per-station mean works) and let the mask discard them:
import jax.numpy as jnp
import numpyro
from xtremax import GeneralizedExtremeValueDistribution as GEV
filled = jnp.where(mask, maxima, station_mean[:, None]) # (S, T)
gev = GEV(loc=mu[:, None], scale=sigma[:, None], concentration=xi[:, None])
numpyro.sample("obs", gev.mask(mask), obs=filled)
numpyro.handlers.mask(mask=mask) around a plain sample is equivalent, as
is summing log_prob yourself into a numpyro.factor:
All three score identically. Prefer the first: factor does register an
observed site, but an auxiliary one carrying Unit(log_factor) rather than the
GEV, so everything downstream sees a summed scalar where the other two keep the
distribution. log_likelihood returns one total per posterior draw instead of
the per-observation matrix WAIC and PSIS-LOO need, and Predictive has no
distribution left to draw the site from.
Why the fill value does not bias the fit
Masked entries contribute neither density nor gradient, so what you write into the gaps cannot move the posterior. This holds even when the filler falls outside the support: the GEV endpoint is parameter-dependent (\(1 + \xi(y-\mu)/\sigma > 0\)), so a per-station mean can sit past a \(\xi < 0\) upper bound at the parameters the sampler happens to be holding.
Genuinely observed maxima are a different matter — one outside the support
at a trial parameter draw scores \(-\infty\), and find_valid_initial_params
rejects that draw (it wants a finite potential and finite gradients) and
tries another, up to 100 times. nan fails the same isfinite test, so the
distinction is not which one gets retried but whether retrying can help: an
out-of-support observation is \(-\infty\) only at some parameters, so a later
draw lands somewhere valid. A nan leaking out of a masked-out gap is nan
at every parameter, and no number of retries recovers from that.
Generalized Pareto¶
The distribution for threshold exceedances (peaks-over-threshold). Pair it with the extraction threshold and declustering utilities: POT uses more of the data than block maxima, at the cost of a threshold choice.
NumPyro-compatible extreme value distributions.
GeneralizedParetoDistribution(scale: ArrayLike = 1.0, concentration: ArrayLike | None = None, shape: ArrayLike | None = None, validate_args: bool | None = None)
¶
Bases: Distribution
Generalized Pareto Distribution (GPD) for NumPyro.
The Generalized Pareto Distribution is fundamental in extreme value theory for modeling threshold exceedances in the Peaks-Over-Threshold (POT) framework. It emerges as the limiting distribution of scaled excesses over high thresholds for a wide class of underlying distributions.
Key Characteristics: - Models excesses above a threshold: Y = X - u | X > u - Three families based on shape parameter ξ: * ξ > 0: Pareto-type (heavy tails, power-law decay) * ξ = 0: Exponential-type (exponential tails) * ξ < 0: Beta-type (bounded support, light tails) - Direct connection to GEVD via POT theory - Foundation for threshold-based extreme value modeling
Probability Density Function:
For ξ ≠ 0: f(x) = (1/σ) * (1 + ξx/σ)^(-(1/ξ + 1))
For ξ = 0 (exponential limit): f(x) = (1/σ) * exp(-x/σ)
Cumulative Distribution Function:
For ξ ≠ 0: F(x) = 1 - (1 + ξx/σ)^(-1/ξ)
For ξ = 0: F(x) = 1 - exp(-x/σ)
Support:
- ξ ≥ 0: x ≥ 0 (non-negative)
- ξ < 0: 0 ≤ x ≤ -σ/ξ (bounded above)
Parameters:
- scale (σ): Scale parameter > 0
- shape (ξ): Shape parameter ∈ ℝ
Connection to GEVD:
If block maxima follow GEVD(μ, σ*, ξ), then threshold excesses follow GPD(σ + ξ(u - μ), ξ) where u is the threshold.
Applications:
- Financial risk: Value-at-Risk, Expected Shortfall modeling
- Hydrology: Flood frequency analysis above design levels
- Insurance: Large claim modeling, catastrophe reinsurance
- Engineering: Structural reliability, extreme load analysis
- Environmental: Pollution exceedances, extreme weather events
- Telecommunications: Network traffic bursts, service failures
Examples:
>>> import jax
>>> import jax.numpy as jnp
>>>
>>> # Heavy-tailed excesses (financial losses)
>>> heavy_tail_gpd = GeneralizedParetoDistribution(scale=1000, shape=0.25)
>>>
>>> # Exponential excesses (reliability applications)
>>> exponential_gpd = GeneralizedParetoDistribution(scale=500, shape=0.0)
>>>
>>> # Bounded excesses (physical constraints)
>>> bounded_gpd = GeneralizedParetoDistribution(scale=100, shape=-0.2)
>>>
>>> # Key properties
>>> print(f"Mean (heavy tail): {heavy_tail_gpd.mean}")
>>> print(f"Upper bound (bounded): {bounded_gpd.upper_bound()}")
>>> print(f"Tail index (heavy): {heavy_tail_gpd.tail_index()}")
>>>
>>> # Sample and analyze
>>> key = jax.random.PRNGKey(42)
>>> samples = heavy_tail_gpd.sample(key, sample_shape=(1000,))
>>> log_probs = heavy_tail_gpd.log_prob(samples)
Initialize the Generalized Pareto Distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scale
|
ArrayLike
|
Scale parameter σ > 0 |
1.0
|
concentration
|
ArrayLike | None
|
Shape parameter ξ ∈ ℝ * ξ > 0: Heavy tails (Pareto-type) * ξ = 0: Exponential tails * ξ < 0: Light tails, bounded support (Beta-type) |
None
|
shape
|
ArrayLike | None
|
Deprecated backward-compatible alias for |
None
|
validate_args
|
bool | None
|
Whether to validate input arguments |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If scale <= 0 |
Source code in src/xtremax/distributions/gpd.py
support: constraints.Constraint
property
¶
Return the support constraint for GPD.
Returns:
| Type | Description |
|---|---|
Constraint
|
Constraint object reflecting the shape-dependent support: |
Constraint
|
|
Constraint
|
|
Only the ξ < 0 case uses interval — its bounds are finite, so
biject_to maps it to a well-behaved Sigmoid ∘ Affine. For
ξ ≥ 0 the old interval(0, inf) construction made biject_to
return inf, breaking NUTS/SVI models with a GPD latent site;
constraints.nonnegative has a registered exp-bijector and
accepts the closed endpoint x = 0.
When the concentration is traced (inside jit/inference) or a
mixed-sign batch, the support falls back to nonnegative — the
lower bound is parameter-independent, and points above a finite
ξ < 0 upper endpoint are handled by log_prob returning -inf.
mean: jnp.ndarray
property
¶
Mean. Thin wrapper for :func:~xtremax.primitives.gpd.gpd_mean.
mode: jnp.ndarray
property
¶
Compute the mode of the GPD.
For ξ > -1 the density is monotone decreasing from x = 0, so the mode is 0 (the threshold). For ξ < -1 the density increases toward the finite upper endpoint -σ/ξ, so the mode is the upper endpoint itself (at ξ = -1, the uniform case, every point is modal and 0 is returned by convention).
Returns:
| Name | Type | Description |
|---|---|---|
Mode |
ndarray
|
0 for ξ ≥ -1, the upper endpoint -σ/ξ for ξ < -1 |
variance: jnp.ndarray
property
¶
Compute the variance of the GPD.
Variance exists when ξ < 1/2:
For ξ < 1/2: Var[X] = σ² / ((1-ξ)²(1-2ξ))
For ξ ≥ 1/2: Var[X] = +∞ (infinite variance)
Returns:
| Type | Description |
|---|---|
ndarray
|
Variance or +∞ when it doesn't exist |
sample(key: jnp.ndarray, sample_shape: tuple = (), *, shape: tuple | None = None) -> jnp.ndarray
¶
Generate samples from the GPD using inverse transform sampling.
The sampling uses the quantile function:
For ξ ≠ 0: Q(p) = (σ/ξ) * ((1-p)^(-ξ) - 1)
For ξ = 0: Q(p) = -σ * ln(1-p)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
ndarray
|
JAX random key for sampling |
required |
sample_shape
|
tuple
|
Shape of samples to generate |
()
|
shape
|
tuple | None
|
Keyword-only alias for |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of samples from the GPD (all within support) |
Source code in src/xtremax/distributions/gpd.py
log_prob(value: jnp.ndarray) -> jnp.ndarray
¶
Log PDF. Thin wrapper for :func:~xtremax.primitives.gpd.gpd_log_prob.
cdf(value: jnp.ndarray) -> jnp.ndarray
¶
icdf(q: jnp.ndarray) -> jnp.ndarray
¶
upper_bound() -> jnp.ndarray
¶
Compute the upper bound of the support.
Returns:
| Type | Description |
|---|---|
ndarray
|
Upper bound: |
ndarray
|
|
ndarray
|
|
Source code in src/xtremax/distributions/gpd.py
lower_bound() -> jnp.ndarray
¶
Compute the lower bound of the support.
Returns:
| Type | Description |
|---|---|
ndarray
|
Lower bound: 0 (always non-negative for GPD) |
covariance() -> jnp.ndarray
¶
Marginal variance broadcast to the batch shape.
Structural seam for pipekit_cycle.ObservationNoise (which
requires covariance() and sample(key, shape)): together
with the existing :meth:sample, this lets the distribution act
as a non-Gaussian observation-error model in data-assimilation
experiments — without xtremax importing pipekit (see
docs/interop.md). The observation errors are treated as
independent per batch element, so the "covariance" is the
marginal variance vector rather than a dense matrix; consuming
analysis steps interpret it as a diagonal.
Returns:
| Type | Description |
|---|---|
ndarray
|
Variance broadcast to |
ndarray
|
variance does not exist, i.e. ξ >= 1/2). |
Source code in src/xtremax/distributions/gpd.py
kurtosis() -> jnp.ndarray
¶
Compute the excess kurtosis of the GPD.
Excess kurtosis exists when ξ < 1/4:
κ = 3(1-2ξ)(2ξ²+ξ+3) / ((1-3ξ)(1-4ξ)) - 3
Returns:
| Type | Description |
|---|---|
ndarray
|
Excess kurtosis or +∞ when it doesn't exist |
Source code in src/xtremax/distributions/gpd.py
skew() -> jnp.ndarray
¶
Compute the skewness of the GPD.
Skewness exists when ξ < 1/3:
γ₃ = 2(1+ξ)√(1-2ξ) / (1-3ξ)
Returns:
| Type | Description |
|---|---|
ndarray
|
Skewness or +∞ when it doesn't exist |
Source code in src/xtremax/distributions/gpd.py
entropy() -> jnp.ndarray
¶
Compute the differential entropy of the GPD.
For the GPD: H = log(σ) + ξ + 1
Returns:
| Type | Description |
|---|---|
ndarray
|
Differential entropy in nats |
Source code in src/xtremax/distributions/gpd.py
survival_function(value: jnp.ndarray) -> jnp.ndarray
¶
Compute the survival function S(x) = 1 - F(x).
For ξ ≠ 0: S(x) = (1 + ξx/σ)^(-1/ξ)
For ξ = 0: S(x) = exp(-x/σ)
This has direct interpretation in POT models as the probability of observing an exceedance larger than x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ndarray
|
Points at which to evaluate survival function |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Survival probabilities |
Source code in src/xtremax/distributions/gpd.py
hazard_rate(value: jnp.ndarray) -> jnp.ndarray
¶
Compute the hazard rate h(x) = f(x) / S(x).
For GPD: h(x) = 1 / (σ + ξx)
This represents the instantaneous failure rate in reliability applications or the rate of threshold exceedance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ndarray
|
Points at which to evaluate hazard rate |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Hazard rate values |
Source code in src/xtremax/distributions/gpd.py
cumulative_hazard_rate(value: jnp.ndarray) -> jnp.ndarray
¶
Compute the cumulative hazard rate Λ(x) = -log(S(x)).
For ξ ≠ 0: Λ(x) = (1/ξ) * log(1 + ξx/σ)
For ξ = 0: Λ(x) = x/σ
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ndarray
|
Points at which to evaluate cumulative hazard rate |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Cumulative hazard rate values |
Source code in src/xtremax/distributions/gpd.py
return_level(return_period: float | jnp.ndarray) -> jnp.ndarray
¶
Return level. Thin wrapper for gpd_return_level.
tail_index() -> jnp.ndarray
¶
Compute the tail index for GPD.
For GPD with ξ > 0: tail index α = 1/ξ For ξ ≤ 0: tail index is not defined (no power-law tail)
Returns:
| Type | Description |
|---|---|
ndarray
|
Tail index (1/ξ for ξ > 0, ∞ otherwise) |
Source code in src/xtremax/distributions/gpd.py
exceedance_probability(threshold: jnp.ndarray) -> jnp.ndarray
¶
Compute probability of exceeding a threshold: P(X > threshold).
This is the survival function and fundamental for POT analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
threshold
|
ndarray
|
Threshold value |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Exceedance probabilities |
Source code in src/xtremax/distributions/gpd.py
conditional_excess_mean(threshold: jnp.ndarray) -> jnp.ndarray
¶
Compute the mean excess function: E[X - u | X > u].
For GPD, this has the simple form: E[X - u | X > u] = (σ + ξu) / (1 - ξ)
This linear relationship is a key property of GPD and forms the basis for threshold selection in POT modeling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
threshold
|
ndarray
|
Threshold value u |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Conditional excess mean values |
Source code in src/xtremax/distributions/gpd.py
threshold_stability_plot_data(thresholds: jnp.ndarray) -> dict
¶
Generate data for threshold stability plots in POT analysis.
Returns modified scale parameters σ* = σ + ξ(u - u₀) for different thresholds, which should be approximately constant if GPD fits well.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
thresholds
|
ndarray
|
Array of threshold values |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with threshold stability metrics |
Source code in src/xtremax/distributions/gpd.py
hill_plot_data(order_statistics: jnp.ndarray, k_values: jnp.ndarray) -> dict
¶
Generate data for Hill plots (tail index estimation).
Computes Hill estimator: α̂k = (1/k) * Σᵢ₌₁ᵏ log(X)} / X_{n-k,n
Vectorized over k_values via a cumulative sum of log order
statistics, so it is safe under jax.jit (the previous Python
loop branched on traced values and raised a TracerBoolConversion
error). Invalid k (≤ 0 or ≥ n) yield NaN.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order_statistics
|
ndarray
|
Sorted sample in descending order |
required |
k_values
|
ndarray
|
Numbers of upper order statistics to use |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with Hill plot data |
Source code in src/xtremax/distributions/gpd.py
expand(batch_shape: tuple[int, ...]) -> dist.Distribution
¶
Expand to batch_shape by reconstructing via __init__.
We deliberately go through the constructor (rather than an
ExpandedDistribution wrapper) so every EVT method stays
available on the returned distribution.
Source code in src/xtremax/distributions/gpd.py
Fixed-type GEV families¶
The three GEV types as standalone distributions, for when theory or prior evidence pins the tail behaviour and you would rather not estimate \(\xi\). Fixing the type removes a parameter and usually tightens return-level intervals — at the cost of an assumption the data can no longer overturn.
| Class | Type | Tail |
|---|---|---|
GumbelType1GEVD |
I (\(\xi = 0\)) | Exponential |
FrechetType2GEVD |
II (\(\xi > 0\)) | Heavy polynomial, lower-bounded |
WeibullType3GEVD |
III (\(\xi < 0\)) | Bounded above |
NumPyro-compatible extreme value distributions.
GumbelType1GEVD(loc: float = 0.0, scale: float = 1.0, validate_args: bool | None = None)
¶
Bases: Gumbel
Gumbel Type I Generalized Extreme Value Distribution for NumPyro.
The distribution core — sample/log_prob/cdf/icdf/
mean/variance/support — is inherited directly from
:class:numpyro.distributions.Gumbel (parameter-for-parameter
identical), so sampling uses numpyro's native tail-accurate
jax.random.gumbel path and the class inherits numpyro's batching
and KL registrations for free. This subclass adds the EVT sugar:
return levels, moments beyond variance, hazard/survival methods, the
characteristic function, and probability-paper utilities.
The Gumbel Type I is the GEVD with shape parameter ξ = 0, characterized by exponential tails and unbounded support. This distribution is the limiting case of the GEVD and represents the "double exponential" distribution for extreme values. It's the most commonly used extreme value distribution in meteorology, hydrology, and engineering applications.
Key Characteristics: - Unbounded support: x ∈ (-∞, +∞) - Exponential tails: P(X > x) ~ exp(-exp((x-μ)/σ)) for large x - Moderate extreme behavior (neither heavy nor light tails) - Asymmetric with positive skewness ≈ 1.14 - Often emerges from block maxima of exponential-type distributions
Probability Density Function:
f(x) = (1/σ) * exp(-z - exp(-z)) where z = (x - μ)/σ
Cumulative Distribution Function:
F(x) = exp(-exp(-z)) where z = (x - μ)/σ
Quantile Function:
Q(p) = μ - σ * ln(-ln(p))
Support:
x ∈ (-∞, +∞) (unbounded)
Tail Behavior:
Upper tail: P(X > x) ~ exp(-exp((x-μ)/σ)) (exponential decay) Lower tail: P(X < x) ~ exp(exp((μ-x)/σ)) (double exponential growth)
Parameters:
- loc (μ): Location parameter ∈ ℝ (mode of the distribution)
- scale (σ): Scale parameter > 0 (controls spread)
Statistical Properties:
- Mean: E[X] = μ + σγ (where γ ≈ 0.5772 is Euler-Mascheroni constant)
- Mode: μ (location parameter)
- Variance: Var[X] = σ²π²/6
- Skewness: γ₃ ≈ 1.1396 (constant, independent of parameters)
- Kurtosis: γ₄ = 12/5 = 2.4 (excess kurtosis, constant)
Applications in Geosciences:
- Daily maximum/minimum temperatures (temperate climates)
- Wind speed extremes (non-hurricane conditions)
- River discharge peaks (regulated systems)
- Wave height extremes (moderate sea states)
- Precipitation extremes (stable atmospheric conditions)
- Seismic background noise levels
- Atmospheric pressure extremes
Examples:
>>> import jax
>>> import jax.numpy as jnp
>>>
>>> # Create Gumbel distribution for temperature extremes
>>> temp_extremes = GumbelType1GEVD(loc=35.0, scale=5.0) # °C
>>>
>>> # Key properties
>>> print(f"Mean temperature: {temp_extremes.mean:.2f}°C")
>>> print(f"Mode (most likely): {temp_extremes.mode:.2f}°C")
>>> print(f"Standard deviation: {jnp.sqrt(temp_extremes.variance):.2f}°C")
>>> print(f"Skewness: {temp_extremes.skew():.3f}")
>>>
>>> # Sample and evaluate
>>> key = jax.random.PRNGKey(42)
>>> samples = temp_extremes.sample(key, sample_shape=(1000,))
>>> log_probs = temp_extremes.log_prob(samples)
>>>
>>> # Return level analysis
>>> return_50yr = temp_extremes.return_level(50)
>>> print(f"50-year return level: {return_50yr:.2f}°C")
Initialize the Gumbel Type I GEVD.
The core distribution machinery is delegated to
:class:numpyro.distributions.Gumbel; only the mathematical
constants used by the EVT sugar methods are set up here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loc
|
float
|
Location parameter μ (mode of distribution) |
0.0
|
scale
|
float
|
Scale parameter σ (positive real number) |
1.0
|
validate_args
|
bool | None
|
Whether to validate input arguments |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If scale <= 0 |
Source code in src/xtremax/distributions/gumbel.py
mode: jnp.ndarray
property
¶
Compute the mode of the Gumbel Type I GEVD.
The mode is simply the location parameter: mode = μ
This is the most likely extreme value and represents the peak of the probability density function.
Returns:
| Type | Description |
|---|---|
ndarray
|
Mode of the distribution (equals location parameter) |
sample(key: jnp.ndarray, sample_shape: tuple = ()) -> jnp.ndarray
¶
Sample via numpyro's native jax.random.gumbel path.
Only adds xtremax's up-front PRNG-key validation (a clear
TypeError instead of numpyro's bare AssertionError) before
delegating to :meth:numpyro.distributions.Gumbel.sample.
Source code in src/xtremax/distributions/gumbel.py
upper_bound() -> jnp.ndarray
¶
Compute the upper bound of the support.
For Gumbel Type I: upper bound = +∞
Returns:
| Type | Description |
|---|---|
ndarray
|
Upper bound (+∞ for Gumbel) |
lower_bound() -> jnp.ndarray
¶
Compute the lower bound of the support.
For Gumbel Type I: lower bound = -∞
Returns:
| Type | Description |
|---|---|
ndarray
|
Lower bound (-∞ for Gumbel) |
kurtosis() -> jnp.ndarray
¶
Compute the excess kurtosis of the Gumbel Type I GEVD.
The excess kurtosis is constant: κ = 12/5 = 2.4
This value is independent of the distribution parameters and indicates heavier tails than the normal distribution (which has κ = 0).
Returns:
| Type | Description |
|---|---|
ndarray
|
Excess kurtosis (constant value 12/5) |
Source code in src/xtremax/distributions/gumbel.py
skew() -> jnp.ndarray
¶
Compute the skewness of the Gumbel Type I GEVD.
The skewness is constant: γ₃ ≈ 1.1396470994
This positive value indicates right-skewness (longer right tail), which is characteristic of extreme value distributions for maxima. The value is independent of distribution parameters.
Returns:
| Type | Description |
|---|---|
ndarray
|
Skewness (constant positive value ≈ 1.14) |
Source code in src/xtremax/distributions/gumbel.py
entropy() -> jnp.ndarray
¶
Compute the differential entropy of the Gumbel Type I GEVD.
The entropy is: H = log(σ) + γ + 1 where γ is the Euler-Mascheroni constant.
This measures the uncertainty in the distribution and increases with the scale parameter.
Returns:
| Type | Description |
|---|---|
ndarray
|
Differential entropy in nats |
Source code in src/xtremax/distributions/gumbel.py
survival_function(value: jnp.ndarray) -> jnp.ndarray
¶
Compute the survival function S(x) = 1 - F(x).
For Gumbel Type I: S(x) = 1 - exp(-exp(-z)) where z = (x - μ)/σ
This represents the probability of exceeding a given value, which is fundamental for risk analysis and return level calculations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ndarray
|
Points at which to evaluate the survival function |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Survival probabilities |
Source code in src/xtremax/distributions/gumbel.py
log_survival_function(value: jnp.ndarray) -> jnp.ndarray
¶
Compute the log survival function log S(x) = log(1 - F(x)).
For extreme quantiles, this provides better numerical stability than computing log(1 - F(x)) directly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ndarray
|
Points at which to evaluate log survival function |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Log survival probabilities |
Source code in src/xtremax/distributions/gumbel.py
hazard_rate(value: jnp.ndarray) -> jnp.ndarray
¶
Hazard rate :math:h(x) = f(x) / S(x) for the Gumbel.
With :math:F(x) = \exp(-e^{-z}) and :math:z = (x - \mu)/\sigma,
:math:S(x) = 1 - F(x) = -\mathrm{expm1}(-e^{-z}), so the hazard
does not simplify to :math:e^{z}/\sigma — the upper-tail limit
is :math:1/\sigma, not diverging.
Source code in src/xtremax/distributions/gumbel.py
cumulative_hazard_rate(value: jnp.ndarray) -> jnp.ndarray
¶
Cumulative hazard :math:\Lambda(x) = -\log S(x) for the Gumbel.
With :math:S(x) = -\mathrm{expm1}(-e^{-z}),
:math:\Lambda(x) = -\log(-\mathrm{expm1}(-e^{-z})).
Source code in src/xtremax/distributions/gumbel.py
return_level(return_period: float | jnp.ndarray) -> jnp.ndarray
¶
Return level. Thin wrapper for gumbel_return_level.
tail_index() -> jnp.ndarray
¶
Compute the tail index for Gumbel Type I GEVD.
For Gumbel distributions, there is no power-law tail behavior. The tail index concept (from extreme value theory) is not applicable since Gumbel has exponential (not polynomial) tails.
Returns:
| Type | Description |
|---|---|
ndarray
|
NaN (tail index not defined for exponential tails) |
Source code in src/xtremax/distributions/gumbel.py
exceedance_probability(threshold: jnp.ndarray) -> jnp.ndarray
¶
Compute probability of exceeding a threshold: P(X > threshold).
This is equivalent to the survival function and follows the double exponential decay characteristic of Gumbel distributions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
threshold
|
ndarray
|
Threshold value |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Exceedance probabilities |
Source code in src/xtremax/distributions/gumbel.py
conditional_excess_mean(threshold: jnp.ndarray) -> jnp.ndarray
¶
Mean excess :math:E[X - u \mid X > u] for the Gumbel.
Computed from the identity
.. math:: E[X - u \mid X > u] \, S(u) = \int_u^\infty S(x)\,dx
via a trapezoidal quadrature over a grid from u to u + 50σ
(well past the Gumbel tail). Works for scalar, batched, and
broadcasted threshold / scale — the grid axis is always
placed last so trapezoidal integration stays on the quadrature
axis rather than the batch axis.
Returns NaN where the survival probability is effectively zero.
Source code in src/xtremax/distributions/gumbel.py
median() -> jnp.ndarray
¶
Compute the median (50th percentile) of the Gumbel Type I GEVD.
The median is: Q(0.5) = μ - σ * ln(-ln(0.5)) = μ - σ * ln(ln(2))
Returns:
| Type | Description |
|---|---|
ndarray
|
Median value of the distribution |
Source code in src/xtremax/distributions/gumbel.py
interquartile_range() -> jnp.ndarray
¶
Compute the interquartile range (IQR) of the Gumbel Type I GEVD.
IQR = Q(0.75) - Q(0.25)
Returns:
| Type | Description |
|---|---|
ndarray
|
Interquartile range |
Source code in src/xtremax/distributions/gumbel.py
coefficient_of_variation() -> jnp.ndarray
¶
Compute the coefficient of variation (CV = σ/μ) for risk assessment.
For Gumbel distributions: CV = (σπ/√6) / (μ + σγ)
Returns:
| Type | Description |
|---|---|
ndarray
|
Coefficient of variation |
Source code in src/xtremax/distributions/gumbel.py
moment_generating_function(t: jnp.ndarray) -> jnp.ndarray
¶
Compute the moment generating function M(t) = E[exp(tX)].
For Gumbel Type I with t < 1/σ: M(t) = exp(μt) * Γ(1 - σt) where Γ is the gamma function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
ndarray
|
Values at which to evaluate MGF (must satisfy t < 1/σ) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Moment generating function values |
Source code in src/xtremax/distributions/gumbel.py
characteristic_function(t: jnp.ndarray) -> jnp.ndarray
¶
Compute the characteristic function φ(t) = E[exp(itX)].
For Gumbel Type I: φ(t) = exp(iμt) * Γ(1 - iσt)
jax.scipy.special.gammaln is real-only, so the complex argument
1 - iσt is evaluated via jax.pure_callback to
scipy.special.loggamma. This is host-hop but numerically
correct — a naive JAX call would have failed or returned garbage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
ndarray
|
Real values at which to evaluate the characteristic function |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Complex-valued characteristic function |
Source code in src/xtremax/distributions/gumbel.py
gumbel_probability_paper_coordinates(value: jnp.ndarray) -> tuple[jnp.ndarray, jnp.ndarray]
¶
Convert values to Gumbel probability paper coordinates for graphical analysis.
Transforms (x, F(x)) to coordinates where the Gumbel CDF appears linear: y-coordinate: -ln(-ln(F(x))) x-coordinate: x (unchanged)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ndarray
|
Data values |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
Tuple of (x-coordinates, y-coordinates) for probability paper |
Source code in src/xtremax/distributions/gumbel.py
expand(batch_shape: tuple[int, ...]) -> dist.Distribution
¶
Expand to batch_shape by reconstructing via __init__.
Going through the constructor re-populates all cached constants
(_pi_squared_over_six, _gumbel_skewness,
_gumbel_kurtosis, _euler_gamma) on the returned instance.
Bypassing __init__ broke variance/skew/kurtosis/
entropy on expanded distributions.
Source code in src/xtremax/distributions/gumbel.py
FrechetType2GEVD(loc: ArrayLike = 0.0, scale: ArrayLike = 1.0, concentration: ArrayLike | None = None, shape: ArrayLike | None = None, validate_args: bool | None = None)
¶
Bases: Distribution
Fréchet Type II Generalized Extreme Value Distribution for NumPyro.
The Fréchet Type II is the GEVD with shape parameter ξ > 0, characterized by heavy polynomial tails and lower-bounded support. This distribution is fundamental in extreme value theory for modeling phenomena with power-law tail behavior, such as financial extreme losses, natural disaster magnitudes, and network traffic bursts.
Key Characteristics: - Lower bounded support: x ≥ μ - σ/ξ (since ξ > 0) - Heavy polynomial tails: P(X > x) ~ x^(-1/ξ) as x → ∞ - Power-law tail index α = 1/ξ - Infinite moments when ξ ≥ 1/k for k-th moment - Models phenomena with "fat tails" and extreme outliers
Probability Density Function:
f(x) = (1/σ) * t(x)^(-(1/ξ + 1)) * exp(-t(x)^(-1/ξ)) where t(x) = 1 + ξ(x - μ)/σ and ξ > 0
Cumulative Distribution Function:
F(x) = exp(-t(x)^(-1/ξ)) for t(x) > 0 F(x) = 0 for t(x) ≤ 0 (below lower bound) where t(x) = 1 + ξ(x - μ)/σ
Support:
x ∈ [μ - σ/ξ, +∞) where μ - σ/ξ is the lower bound
Tail Behavior:
P(X > x) ~ C * x^(-1/ξ) as x → ∞, where C is a constant This gives tail index α = 1/ξ, with smaller ξ meaning heavier tails
Parameters:
- loc (μ): Location parameter ∈ ℝ
- scale (σ): Scale parameter > 0
- shape (ξ): Shape parameter > 0 (enforced for Type II)
Statistical Properties:
- Mean exists for ξ < 1: E[X] = μ + (σ/ξ)(Γ(1-ξ) - 1)
- Variance exists for ξ < 1/2: Var[X] = (σ²/ξ²)(Γ(1-2ξ) - Γ²(1-ξ))
- k-th moment exists for ξ < 1/k
- Heavy right tail makes it suitable for extreme event modeling
Examples:
>>> import jax
>>> import jax.numpy as jnp
>>>
>>> # Create Fréchet Type II GEVD with different tail heaviness
>>> light_tail = FrechetType2GEVD(loc=0.0, scale=1.0, shape=0.1) # α = 10
>>> heavy_tail = FrechetType2GEVD(loc=0.0, scale=1.0, shape=0.8) # α = 1.25
>>>
>>> # Key properties
>>> print(f"Lower bound: {heavy_tail.lower_bound()}")
>>> print(f"Tail index: {heavy_tail.tail_index()}")
>>> print(f"Mean exists: {heavy_tail.concentration < 1}")
>>>
>>> # Sample and evaluate
>>> key = jax.random.PRNGKey(42)
>>> samples = heavy_tail.sample(key, sample_shape=(1000,))
>>> log_probs = heavy_tail.log_prob(samples)
Initialize the Fréchet Type II GEVD.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loc
|
ArrayLike
|
Location parameter μ (real number) |
0.0
|
scale
|
ArrayLike
|
Scale parameter σ (positive real number) |
1.0
|
concentration
|
ArrayLike | None
|
Shape parameter ξ (positive real number, ξ > 0) |
None
|
shape
|
ArrayLike | None
|
Deprecated backward-compatible alias for |
None
|
validate_args
|
bool | None
|
Whether to validate input arguments |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/xtremax/distributions/frechet.py
support: constraints.Constraint
property
¶
Return the support constraint for Fréchet Type II GEVD.
Returns:
| Type | Description |
|---|---|
Constraint
|
|
Constraint
|
endpoint (matching the closed |
Constraint
|
class always had; the density vanishes there so |
Constraint
|
is -inf). The old |
Constraint
|
|
Constraint
|
with a Fréchet latent site; |
Constraint
|
registered bijector that handles the unbounded tail. |
mean: jnp.ndarray
property
¶
Mean. Thin wrapper for :func:~xtremax.primitives.frechet.frechet_mean.
mode: jnp.ndarray
property
¶
Compute the mode of the Fréchet Type II GEVD.
The mode is: mode = μ + (σ/ξ) * ((1+ξ)^(-ξ) - 1)
This represents the most likely value in the heavy-tailed distribution.
Returns:
| Type | Description |
|---|---|
ndarray
|
Mode of the distribution |
variance: jnp.ndarray
property
¶
Compute the variance of the Fréchet Type II GEVD.
The variance exists when ξ < 1/2: Var[X] = (σ²/ξ²) * (Γ(1-2ξ) - Γ²(1-ξ))
For very heavy tails (ξ ≥ 1/2), the variance is infinite.
Returns:
| Type | Description |
|---|---|
ndarray
|
Variance or +∞ when it doesn't exist (ξ ≥ 1/2) |
sample(key: jnp.ndarray, sample_shape: tuple = ()) -> jnp.ndarray
¶
Generate samples from the Fréchet Type II GEVD using inverse transform sampling.
The sampling uses the quantile function: Q(p) = μ + (σ/ξ) * ((-ln(p))^(-ξ) - 1)
Since ξ > 0, this generates samples with heavy right tails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
ndarray
|
JAX random key for sampling |
required |
sample_shape
|
tuple
|
Shape of samples to generate |
()
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of samples from the Fréchet Type II GEVD, all above lower bound |
Source code in src/xtremax/distributions/frechet.py
log_prob(value: jnp.ndarray) -> jnp.ndarray
¶
Log PDF. Thin wrapper for frechet_log_prob.
cdf(value: jnp.ndarray) -> jnp.ndarray
¶
CDF. Thin wrapper for :func:~xtremax.primitives.frechet.frechet_cdf.
icdf(q: jnp.ndarray) -> jnp.ndarray
¶
upper_bound() -> jnp.ndarray
¶
Compute the upper bound of the support.
For Fréchet Type II: upper bound = +∞
Returns:
| Type | Description |
|---|---|
ndarray
|
Upper bound (+∞ for Type II) |
lower_bound() -> jnp.ndarray
¶
Compute the lower bound of the support.
For Fréchet Type II (ξ > 0): lower bound = μ - σ/ξ
Returns:
| Type | Description |
|---|---|
ndarray
|
Lower bound of the distribution support |
Source code in src/xtremax/distributions/frechet.py
kurtosis() -> jnp.ndarray
¶
Compute the excess kurtosis of the Fréchet Type II GEVD.
Excess kurtosis exists when ξ < 1/4 and involves fourth-order moments. For heavy-tailed distributions, kurtosis captures the tail heaviness.
Returns:
| Type | Description |
|---|---|
ndarray
|
Excess kurtosis, or NaN when it doesn't exist (ξ ≥ 1/4) |
Source code in src/xtremax/distributions/frechet.py
skew() -> jnp.ndarray
¶
Compute the skewness of the Fréchet Type II GEVD.
Skewness exists when ξ < 1/3 and involves third-order moments.
For Fréchet Type II, skewness is typically positive due to the heavy right tail creating right-skewed distributions.
Returns:
| Type | Description |
|---|---|
ndarray
|
Skewness, or NaN when it doesn't exist (ξ ≥ 1/3) |
Source code in src/xtremax/distributions/frechet.py
entropy() -> jnp.ndarray
¶
Compute the differential entropy of the Fréchet Type II GEVD.
The entropy is: H = log(σ) + 1 + γ * (1 + ξ)
where γ is the Euler-Mascheroni constant ≈ 0.5772. This is the
standard GEV entropy formula evaluated at the Fréchet branch
(ξ > 0); at ξ = 0 it reduces to the Gumbel entropy log σ + 1 + γ.
Returns:
| Type | Description |
|---|---|
ndarray
|
Differential entropy in nats |
Source code in src/xtremax/distributions/frechet.py
survival_function(value: jnp.ndarray) -> jnp.ndarray
¶
Compute the survival function S(x) = 1 - F(x).
For Fréchet Type II, this exhibits power-law decay: S(x) ~ C * x^(-1/ξ) for large x, where C is a constant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ndarray
|
Points at which to evaluate the survival function |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Survival probabilities (power-law tail behavior) |
Source code in src/xtremax/distributions/frechet.py
log_survival_function(value: jnp.ndarray) -> jnp.ndarray
¶
Compute the log survival function log S(x) = log(1 - F(x)).
For heavy-tailed distributions, this provides better numerical stability for extreme quantiles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ndarray
|
Points at which to evaluate log survival function |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Log survival probabilities |
Source code in src/xtremax/distributions/frechet.py
hazard_rate(value: jnp.ndarray) -> jnp.ndarray
¶
Compute the hazard rate h(x) = f(x) / S(x).
For Fréchet Type II, the hazard rate approaches zero as x → ∞, indicating decreasing failure rates for extreme values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ndarray
|
Points at which to evaluate the hazard rate |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Hazard rate values |
Source code in src/xtremax/distributions/frechet.py
cumulative_hazard_rate(value: jnp.ndarray) -> jnp.ndarray
¶
Compute the cumulative hazard rate Λ(x) = -log(S(x)).
This represents the accumulated hazard up to time x. For Fréchet Type II, this grows slower than exponentially.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ndarray
|
Points at which to evaluate the cumulative hazard rate |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Cumulative hazard rate values |
Source code in src/xtremax/distributions/frechet.py
return_level(return_period: float | jnp.ndarray) -> jnp.ndarray
¶
Return level. Thin wrapper for frechet_return_level.
tail_index() -> jnp.ndarray
¶
Compute the tail index α = 1/ξ for Fréchet Type II GEVD.
The tail index characterizes the power-law tail behavior: P(X > x) ~ x^(-α) as x → ∞
Lower values of α (higher ξ) indicate heavier tails.
Returns:
| Type | Description |
|---|---|
ndarray
|
Tail index α = 1/ξ |
Source code in src/xtremax/distributions/frechet.py
exceedance_probability(threshold: jnp.ndarray) -> jnp.ndarray
¶
Compute probability of exceeding a threshold: P(X > threshold).
For large thresholds, this exhibits power-law decay: P(X > x) ~ C * x^(-1/ξ)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
threshold
|
ndarray
|
Threshold value |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Exceedance probabilities (power-law tail behavior) |
Source code in src/xtremax/distributions/frechet.py
conditional_excess_mean(threshold: jnp.ndarray) -> jnp.ndarray
¶
Mean excess :math:E[X - u \mid X > u] for Fréchet Type II GEVD.
Computed via quantile-space quadrature, same machinery as the
general GEV class. The previous GPD linear approximation
:math:(\sigma + \xi(u - \mu)) / (1 - \xi) is only the POT
asymptote, not the finite-threshold mean excess.
Returns NaN for :math:\xi \ge 1 (heavy tails where the mean
does not exist).
Source code in src/xtremax/distributions/frechet.py
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 | |
hill_estimator_threshold(quantile: float = 0.95) -> jnp.ndarray
¶
Suggest threshold for Hill tail index estimation.
For Fréchet distributions, the threshold should be high enough to be in the tail region but low enough to have sufficient data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
quantile
|
float
|
Quantile level for threshold selection |
0.95
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Suggested threshold for tail analysis |
Source code in src/xtremax/distributions/frechet.py
pareto_tail_approx(threshold: jnp.ndarray) -> tuple[jnp.ndarray, jnp.ndarray]
¶
Generalized Pareto approximation for excesses over threshold.
For Fréchet GEVD, excesses over high thresholds approximately follow GPD(σ, ξ) where: σ = σ + ξ(u - μ) (modified scale) ξ remains the same (shape parameter)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
threshold
|
ndarray
|
Threshold value for POT modeling |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
Tuple of (GPD scale parameter, GPD shape parameter) |
Source code in src/xtremax/distributions/frechet.py
value_at_risk(alpha: float) -> jnp.ndarray
¶
Compute Value-at-Risk (VaR) at confidence level α.
VaR_α = Q(α) where Q is the quantile function. For heavy-tailed distributions, VaR can be very large.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha
|
float
|
Confidence level (e.g., 0.95, 0.99, 0.999) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Value-at-Risk at confidence level α |
Source code in src/xtremax/distributions/frechet.py
expected_shortfall(alpha: float) -> jnp.ndarray
¶
Compute Expected Shortfall (Conditional VaR) at confidence level α.
ES_α = E[X | X > VaR_α] for Fréchet distributions. This captures the expected loss beyond the VaR threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha
|
float
|
Confidence level (e.g., 0.95, 0.99, 0.999) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Expected Shortfall at confidence level α |
Source code in src/xtremax/distributions/frechet.py
power_law_scaling(scale_factor: float) -> jnp.ndarray
¶
Compute scaling relationship for power-law tails.
For Fréchet distributions: if X ~ Fréchet(μ,σ,ξ), then aX has tail behavior ~ (ax)^(-1/ξ) = a^(-1/ξ) * x^(-1/ξ)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scale_factor
|
float
|
Scaling factor a > 0 |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Relative change in tail probabilities under scaling |
Source code in src/xtremax/distributions/frechet.py
expand(batch_shape: tuple[int, ...]) -> dist.Distribution
¶
Expand to batch_shape by reconstructing via __init__.
Source code in src/xtremax/distributions/frechet.py
WeibullType3GEVD(loc: ArrayLike = 0.0, scale: ArrayLike = 1.0, concentration: ArrayLike | None = None, shape: ArrayLike | None = None, validate_args: bool | None = None)
¶
Bases: Distribution
Weibull Type III Generalized Extreme Value Distribution for NumPyro.
The Weibull Type III (reversed Weibull) is the GEVD with shape parameter ξ < 0, characterized by a bounded upper tail. This distribution is fundamental in extreme value theory for modeling bounded maxima and reliability applications with upper failure limits.
Key Characteristics: - Bounded upper tail: x ≤ μ - σ/ξ (since ξ < 0) - Light tail behavior with exponential decay - Often used for modeling material strength limits, maximum system capacity - Opposite tail behavior to Fréchet (Type II)
Probability Density Function:
f(x) = (1/σ) * t(x)^(-(1/ξ + 1)) * exp(-t(x)^(-1/ξ)) where t(x) = 1 + ξ(x - μ)/σ and ξ < 0
Cumulative Distribution Function:
F(x) = exp(-t(x)^(-1/ξ)) for t(x) > 0 F(x) = 1 for t(x) ≤ 0 (above upper bound) where t(x) = 1 + ξ(x - μ)/σ
Support:
x ∈ (-∞, μ - σ/ξ] where μ - σ/ξ is the upper bound
Parameters:
- loc (μ): Location parameter ∈ ℝ
- scale (σ): Scale parameter > 0
- shape (ξ): Shape parameter < 0 (enforced for Type III)
Statistical Properties:
- Mean exists for ξ > -1: E[X] = μ + (σ/ξ)(Γ(1-ξ) - 1)
- Variance exists for ξ > -1/2: Var[X] = (σ²/ξ²)(Γ(1-2ξ) - Γ²(1-ξ))
- Upper bounded support makes it suitable for reliability analysis
Examples:
>>> import jax
>>> import jax.numpy as jnp
>>>
>>> # Create Weibull Type III GEVD
>>> weibull_gevd = WeibullType3GEVD(loc=10.0, scale=2.0, shape=-0.3)
>>>
>>> # Key properties
>>> print(f"Upper bound: {weibull_gevd.upper_bound()}")
>>> print(f"Mean: {weibull_gevd.mean}")
>>> print(f"Mode: {weibull_gevd.mode}")
>>>
>>> # Sample and evaluate
>>> key = jax.random.PRNGKey(42)
>>> samples = weibull_gevd.sample(key, sample_shape=(1000,))
>>> log_probs = weibull_gevd.log_prob(samples)
Initialize the Weibull Type III GEVD.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loc
|
ArrayLike
|
Location parameter μ (real number) |
0.0
|
scale
|
ArrayLike
|
Scale parameter σ (positive real number) |
1.0
|
concentration
|
ArrayLike | None
|
Shape parameter ξ (negative real number, ξ < 0) |
None
|
shape
|
ArrayLike | None
|
Deprecated backward-compatible alias for |
None
|
validate_args
|
bool | None
|
Whether to validate input arguments |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/xtremax/distributions/weibull.py
support: constraints.Constraint
property
¶
Return the support constraint for Weibull Type III GEVD.
Returns:
| Type | Description |
|---|---|
Constraint
|
|
Constraint
|
endpoint (the endpoint density is finite at ξ = -1 and diverges |
Constraint
|
for ξ < -1, so the endpoint is a genuine support point). The old |
Constraint
|
|
Constraint
|
return nan/inf, breaking NUTS/SVI models with a Weibull latent |
Constraint
|
site; |
Constraint
|
the unbounded lower tail. |
mean: jnp.ndarray
property
¶
Mean. Thin wrapper for :func:~xtremax.primitives.weibull.weibull_mean.
mode: jnp.ndarray
property
¶
Compute the mode of the Weibull Type III GEVD.
The mode is: mode = μ + (σ/ξ) * ((1+ξ)^(-ξ) - 1)
This interior stationary point only exists for -1 < ξ < 0. For ξ ≤ -1, the density increases all the way to the finite upper endpoint, so the mode is the upper bound itself.
Returns:
| Type | Description |
|---|---|
ndarray
|
Mode of the distribution |
variance: jnp.ndarray
property
¶
Compute the variance of the Weibull Type III GEVD.
Var[X] = (σ²/ξ²) * (Γ(1-2ξ) - Γ²(1-ξ))
For Weibull Type III, ξ < 0 means the distribution is bounded
above, so all moments exist for every valid ξ in the Type III
range (no guard is needed). The earlier guard ξ > -1/2 was
mistakenly inherited from the Fréchet moment-existence condition
reflected to negative ξ; it silently returned NaN for valid
shapes like ξ = -1.
Returns:
| Type | Description |
|---|---|
ndarray
|
Variance (always finite on the Type III domain). |
sample(key: jnp.ndarray, sample_shape: tuple = ()) -> jnp.ndarray
¶
Generate samples from the Weibull Type III GEVD via inverse transform sampling.
The sampling uses the quantile function: Q(p) = μ + (σ/ξ) * ((-ln(p))^(-ξ) - 1)
Since ξ < 0, this becomes: Q(p) = μ + (σ/|ξ|) * (1 - (-ln(p))^(|ξ|))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
ndarray
|
JAX random key for sampling |
required |
sample_shape
|
tuple
|
Shape of samples to generate |
()
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of samples from the Weibull Type III GEVD, all bounded above |
Source code in src/xtremax/distributions/weibull.py
log_prob(value: jnp.ndarray) -> jnp.ndarray
¶
Log PDF. Thin wrapper for weibull_log_prob.
cdf(value: jnp.ndarray) -> jnp.ndarray
¶
CDF. Thin wrapper for :func:~xtremax.primitives.weibull.weibull_cdf.
icdf(q: jnp.ndarray) -> jnp.ndarray
¶
upper_bound() -> jnp.ndarray
¶
Compute the upper bound of the support.
For Weibull Type III (ξ < 0): upper bound = μ - σ/ξ
Returns:
| Type | Description |
|---|---|
ndarray
|
Upper bound of the distribution support |
Source code in src/xtremax/distributions/weibull.py
lower_bound() -> jnp.ndarray
¶
Compute the lower bound of the support.
For Weibull Type III: lower bound = -∞
Returns:
| Type | Description |
|---|---|
ndarray
|
Lower bound (-∞ for Type III) |
kurtosis() -> jnp.ndarray
¶
Compute the excess kurtosis of the Weibull Type III GEVD.
κ = μ₄/σ⁴ - 3
As with variance, every moment exists for every ξ < 0 (bounded
support), so no ξ > -1/4 guard is applied.
Returns:
| Type | Description |
|---|---|
ndarray
|
Excess kurtosis (always finite on the Type III domain). |
Source code in src/xtremax/distributions/weibull.py
skew() -> jnp.ndarray
¶
Compute the skewness of the Weibull Type III GEVD.
For Weibull Type III, skewness is typically negative due to the upper bound creating left-skewed distributions. All moments exist across the full valid ξ < 0 range.
Returns:
| Type | Description |
|---|---|
ndarray
|
Skewness (always finite on the Type III domain). |
Source code in src/xtremax/distributions/weibull.py
entropy() -> jnp.ndarray
¶
Compute the differential entropy of the Weibull Type III GEVD.
The entropy is: H = log(σ) + 1 + γ * (1 + ξ)
where γ is the Euler-Mascheroni constant ≈ 0.5772. This is the
standard GEV entropy formula evaluated at the Weibull branch
(ξ < 0); at ξ = 0 it reduces to the Gumbel entropy
log σ + 1 + γ.
Returns:
| Type | Description |
|---|---|
ndarray
|
Differential entropy in nats |
Source code in src/xtremax/distributions/weibull.py
survival_function(value: jnp.ndarray) -> jnp.ndarray
¶
Compute the survival function S(x) = 1 - F(x).
For Weibull Type III, this represents the probability of not exceeding the value x, which is relevant for reliability analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ndarray
|
Points at which to evaluate the survival function |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Survival probabilities |
Source code in src/xtremax/distributions/weibull.py
log_survival_function(value: jnp.ndarray) -> jnp.ndarray
¶
Compute the log survival function log S(x) = log(1 - F(x)).
Directly evaluates log(-expm1(log F)) to keep the near-upper-
endpoint regime numerically stable for hazard/cumulative-hazard
consumers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ndarray
|
Points at which to evaluate log survival function |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Log survival probabilities |
Source code in src/xtremax/distributions/weibull.py
hazard_rate(value: jnp.ndarray) -> jnp.ndarray
¶
Compute the hazard rate h(x) = f(x) / S(x).
The hazard rate represents the instantaneous failure rate given survival up to time x. For Weibull Type III, the hazard rate approaches infinity as x approaches the upper bound.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ndarray
|
Points at which to evaluate the hazard rate |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Hazard rate values |
Source code in src/xtremax/distributions/weibull.py
cumulative_hazard_rate(value: jnp.ndarray) -> jnp.ndarray
¶
Compute the cumulative hazard rate Λ(x) = -log(S(x)).
This represents the accumulated hazard up to time x. For Weibull Type III, this is finite at the upper bound.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ndarray
|
Points at which to evaluate the cumulative hazard rate |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Cumulative hazard rate values |
Source code in src/xtremax/distributions/weibull.py
return_level(return_period: float | jnp.ndarray) -> jnp.ndarray
¶
Return level. Thin wrapper for weibull_return_level.
tail_index() -> jnp.ndarray
¶
Compute the tail index for Weibull Type III GEVD.
For Weibull Type III (ξ < 0), there is no power law tail behavior. Instead, the tail is exponentially bounded. The concept of tail index (1/ξ) is not meaningful for bounded distributions.
Returns:
| Type | Description |
|---|---|
ndarray
|
NaN (tail index not defined for bounded distributions) |
Source code in src/xtremax/distributions/weibull.py
exceedance_probability(threshold: jnp.ndarray) -> jnp.ndarray
¶
Compute probability of exceeding a threshold: P(X > threshold).
For Weibull Type III, this is 0 when threshold ≥ upper bound.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
threshold
|
ndarray
|
Threshold value |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Exceedance probabilities (0 above upper bound) |
Source code in src/xtremax/distributions/weibull.py
conditional_excess_mean(threshold: jnp.ndarray) -> jnp.ndarray
¶
Mean excess :math:E[X - u \mid X > u] for Weibull Type III GEVD.
Computed via quantile-space quadrature, same as the general GEV
class. The previous GPD linear approximation
:math:(\sigma + \xi(u - \mu)) / (1 - \xi) is the POT asymptote
and is wrong for finite thresholds. As :math:u approaches the
upper endpoint :math:\mu - \sigma/\xi, the quadrature
correctly decays to zero.
Source code in src/xtremax/distributions/weibull.py
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 | |
reliability_function(time: jnp.ndarray) -> jnp.ndarray
¶
Compute the reliability function R(t) = P(X > t).
This is equivalent to the survival function but emphasizes the reliability engineering interpretation for Weibull Type III.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Time points for reliability evaluation |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Reliability values (probability of surviving past time t) |
Source code in src/xtremax/distributions/weibull.py
mean_residual_life(time: jnp.ndarray) -> jnp.ndarray
¶
Compute the mean residual life function: E[X - t | X > t].
For reliability applications, this represents the expected additional lifetime given survival to time t.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Current time/age |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Mean residual life values |
Source code in src/xtremax/distributions/weibull.py
percentile_residual_life(time: jnp.ndarray, percentile: float) -> jnp.ndarray
¶
Compute percentile residual life: (Q(p|X>t) - t).
This gives the additional time until the p-th percentile failure, conditional on survival to time t.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
Current time/age |
required |
percentile
|
float
|
Percentile level (0 < percentile < 1) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Percentile residual life values |
Source code in src/xtremax/distributions/weibull.py
expand(batch_shape: tuple[int, ...]) -> dist.Distribution
¶
Expand to batch_shape by reconstructing via __init__.