Skip to content

pyextremes

Extreme Value Analysis (EVA) in Python

Test Coverage Docs PyPI Package Python Versions Anaconda Package


pyextremes is a Python library aimed at performing univariate Extreme Value Analysis (EVA).


Features

pyextremes provides tools necessary to perform a wide range of tasks required to perform univariate EVA, such as:

  • extraction of extreme events from time series using methods such as Block Maxima (BM) or Peaks Over Threshold (POT)
  • fitting continuous distributions, such as GEVD, GPD, or user-specified continuous distributions to the extracted extreme events
  • visualization of model inputs, results, and goodness-of-fit statistics
  • estimation of extreme events of given probability or return period (e.g. 100-year event) and of corresponding confidence intervals
  • tools assisting with model selection and tuning, such as selection of block size in BM and threshold in POT

The framework provided by pyextremes is easy to use and requires minimal user input to get production-ready results. Its default parameters follow established industry practice and the underlying models are firmly grounded in Extreme Value Theory. The largest source of inspiration for this library was the book An Introduction to Statistical Modeling of Extreme Values by Stuart Coles (2001).

In addition to the easy-to-use interface, the library provides access to the underlying tools which can be used to build custom models. All scipy continuous distributions are supported out-of-the-box. Custom distributions can also be provided by subclassing scipy.stats.rv_continuous. Any parameter of a distribution may be frozen to investigate degenerate models (e.g. GEVD -> Gumbel or GPD -> Exponential).

Multiple ways of fitting the continuous distributions to the data are supported:

  • MLE (default model) - Maximum Likelihood Estimate, uses SciPy
  • Emcee - Markov Chain Monte Carlo, see Emcee package by Dan Foreman-Mackey
  • MOM - Method of Moments, uses SciPy
  • Lmoments - L-moments, uses lmoments3

Installation

pyextremes supports Python 3.9 to 3.14 and works with pandas 1.x, 2.x, and 3.x.

Get latest version from PyPI:

pip install pyextremes

Or add it to a project managed by uv:

uv add pyextremes

Install with all optional dependencies:

pip install "pyextremes[full]"

Get latest experimental build from GitHub:

pip install "pyextremes @ git+https://github.com/georgebv/pyextremes.git"

For Anaconda Python distributions:

conda install -c conda-forge pyextremes

Dependencies

Package Description
emcee fit models using the Markov Chain Monte Carlo method
matplotlib produce figures
numpy perform efficient operations with arrays
pandas Series and DataFrame objects for model input and output
scipy statistical models and mathematical functions

Optional Dependencies

Optional dependencies can be installed all at once using the full extra as shown above, individually using the lmoments extra (pip install "pyextremes[lmoments]"), or manually:

Package Description
tqdm progress bar for slow processes
lmoments3 support for Lmoments model

License

This project is licensed under the terms of the MIT license.