environmentaltools.temporal.au2

environmentaltools.temporal.au2(par, data)[source]

Calculate Anderson-Darling test statistic for GPD goodness-of-fit.

Computes the Anderson-Darling A² statistic to assess how well a Generalized Pareto Distribution fits the data. Lower values indicate better fit.

Parameters:
  • par (array-like) – GPD parameters [shape, loc, scale]

  • data (array-like) – Peak over threshold data to test

Returns:

Anderson-Darling A² test statistic

Return type:

float

Notes

The Anderson-Darling statistic is:

A² = n/2 - 2Σ[F(x_i)] - Σ[(2i-1)/n * log(1-F(x_i))]

where F is the fitted CDF and x_i are the sorted data.

This statistic gives more weight to tail deviations than KS test, making it particularly suitable for extreme value analysis.

The CDF values are adjusted by 1e-6 to avoid log(0) issues.

References

Anderson, T.W. and Darling, D.A. (1952). “Asymptotic theory of certain goodness of fit criteria based on stochastic processes”. Annals of Mathematical Statistics, 23, 193-212.

Examples

>>> data = np.random.exponential(2.0, 100)
>>> par = [0, 0, 2.0]  # Exponential is GPD with shape=0
>>> ad_stat = au2(par, data)
>>> print(f"Anderson-Darling statistic: {ad_stat:.3f}")