Skip to main content

Modeling Nonstationary Extreme Value Distributions

Project description

nsEVDx: A python Library for modelling non-stationary extreme value distributions

Python License DOI

nsEVDx is a Python library for estimating the parameters of Generalized Extreme Value (GEV) and Generalized Pareto Distributions (GPD), collectively referred to as extreme value distributions (EVDs), under both stationary and non-stationary assumptions, using frequentist and Bayesian methods. Designed for hydrologists, climate scientists, and engineers, especially those working on extreme rainfall or flood frequency analysis, it supports time-varying covariates, MCMC samplings (Metropolis hasting-Randomwalk, Adjusted Langevin Algorithm, Hamiltonian Monte Carlo) and essential model diagnostics. Although developed for environmental extremes, its features are broadly applicable to financial risk modeling and other domains concerned with rare, high-impact events.

Features

  • Fits stationary and nonstationary EVDs
  • Supports Frequentist and Bayesian inference
  • Transparent, fully customizable MCMC engine implemented in NumPy
  • Advanced samplers: Metropolis Hasting RandomWalk, Metropolis Adjusted Langevin Algorithm (MALA), and Hamiltonian Monte Carlo (HMC)
  • Support arbitratry covariates in location, scale and shape parameters
  • Integrated diagnostic tools: trace plots, acceptance rates, and bayesian metrics
  • Visualization tool for posterior summaries
  • Lightweight and minimal dependency, only numpy, scipy, matplotlib, seaborn

Implementation

The core NonStationaryEVD class handles parameter parsing, log-likelihood construction, prior specification, and proposal generation. Frequentist estimation uses scipy.optimize to minimize the negative log-likelihood, while Bayesian MCMC methods are implemented in numpy for transparency and flexibility.

Non-stationarity is controlled via a configuration vector config = [a, b, c], where each entry specifies the number of covariates used to model the location, scale, and shape parameters of the EVD. Entry with a value of 0 implies stationarity, while values > 0 indicate non-stationary modeling using that many covariates.

In Bayesian estimation, nsEVDx can infer prior specifications based on the data and configuration or accept user-defined priors. In the frequentist mode, it can determine suitable parameter bounds automatically. However, user defined priors or bounds are recommended for better convergence and interpretability.

Installation

For regular users

pip install nsEVDx  

# Or clone from GitHub:
git clone https://github.com/Nischalcs50/nsEVDx
cd nsEVDx
pip install .

For developers/contributors

git clone https://github.com/Nischalcs50/nsEVDx
cd nsEVDx
pip install -e .[dev]

Quick Start

from nsEVDx import NonStationaryEVD

sampler = NonStationaryEVD(...)
posterior, acc_rate = sampler.MH_RandWalk(...)

Documentation

See Documentation for full API and usage examples.

Usage

The usage document is available here. For more details, see the usage examples in the Jupyter notebooks here.

Dependencies

  • numpy
  • scipy
  • matplotlib, seaborn (for plots)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Citation

If you use nsEVDx in your research, please cite:

Kafle, N., & Meier, C. (2025). nsEVDx: A Python Library for modeling non-stationary extreme value distributions. Journal of Open Source Software, XX(XX), XXX. DOI: [TBD]

Contributing

Please see CONTRIBUTING.md for guidelines on contributing to this project, and refer to our Code of Conduct to foster an inclusive and respectful community.

References

  • Betancourt, M. (2017). A Conceptual Introduction to Hamiltonian Monte Carlo. arXiv: Methodology.
  • Coles, S. (2007). An introduction to statistical modeling of extreme values (4th. printing). Springer. https://doi.org/10.1007/978-1-4471-3675-0
  • Gilleland, E. (2025). extRemes: Extreme Value Analysis. https://doi.org/10.326 14/CRAN.package.extRemes
  • Heffernan J. E., Stephenson A.G., & Gilleland E. (2003). Ismev: An Introduction to Statistical Modeling of Extreme Values. https://CRAN.R-project.org/pa ckage=ismev
  • Hosking, J. R. M., & Wallis, J. R. (1997). Regional Frequency Analysis: An Approach Based on L-Moments (Vol. 93). Cambridge University Press. https://doi.org/10.1017/cbo97805 11529443
  • IRSN. (2024). NSGEV: Non-Stationary GEV Time Series. https://github.com /IRSN/NSGEV/
  • Kafle, N., & Meier, C. (n.d.). Detecting trends in short duration extreme precipitation over SEUS using neighborhood based method. Manuscript in Preparation.
  • Kafle, N., & Meier, C. (2025). Evaluating Methodologies for Detecting Trends in Short-Duration Extreme Rainfall in the Southeastern United States. Extreme Hydrological or Critical Event Analysis-III, EWRI Congress 2025, Anchorage, AK, U.S. <https://alaska2025.eventscribe.net
  • Oriol Abril-Pla, Virgile Andreani, C. Carroll, L. Y. Dong, Christopher Fonnesbeck, Maxim Kochurov, Ravin Kumar, Junpeng Lao, Christian C. Luhmann, Osvaldo A. Martin, Michael Osthege, Ricardo Vieira, Thomas V. Wiecki, & Robert Zinkov. (2023). PyMC: A modern, and comprehensive probabilistic programming framework in Python. PeerJ Computer Science, 9, e1516--e1516. https://doi.org/10.7717/peerj-cs.1516
  • Paciorek, C. (2016). climextRemes: Tools for Analyzing Climate Extremes. https://CRAN.R-project.org/package=climextRemes
  • Robert, C. P., & Casella, G. (2009). Introducing Monte Carlo Methods with R. https://doi.org/10.1007/978-1-4419-1576-4
  • Roberts, G. O., & Tweedie, R. L. (1996). Exponential Convergence of Langevin Distributions and Their Discrete Approximations. Bernoulli, 2 (4), 341. https://doi.org/10.2307/3318418
  • Stan development Team. (2023a). CmdStan: The command-line interface to Stan. https://mc-stan.org/users/interfaces/cmdstan
  • Stan development Team. (2023b). PyStan: The python interface to Stan. https://pystan.readthedocs.io/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nsevdx-0.1.0.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nsevdx-0.1.0-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file nsevdx-0.1.0.tar.gz.

File metadata

  • Download URL: nsevdx-0.1.0.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for nsevdx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5abbf2920ca367c0fae8120740d39e118b8adf486a3032c8732f6cfad47d24b9
MD5 b89c8245c63c7b1992a6effa6271d0de
BLAKE2b-256 762c5aa065a4c260f89fe69cea46fbf3a11af5cc3ce5ccf95caaf5b47ef7e1e5

See more details on using hashes here.

File details

Details for the file nsevdx-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nsevdx-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for nsevdx-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 95e383883d7eafa122310a8cb7281f2faf1ed55ae38ecf5024fbcc3f612ab6bc
MD5 4cf090937e578a437a7439742867356b
BLAKE2b-256 3fd4caa9273209070c80da7e1dab198d2cb4b110b1680ad0993eff962e0d2df2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page