nsEVDx 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
nsevdx-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Nischal Kafle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "nsEVDx"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
nsevdx-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.4
2
+ Name: nsEVDx
3
+ Version: 0.1.0
4
+ Summary: Modeling Nonstationary Extreme Value Distributions
5
+ Home-page: https://github.com/Nischalcs50/nsEVDx
6
+ Author: Nischal Kafle
7
+ Author-email: Nischal Kafle <nkafle.29@gmail.com>, Claudio Meier <cimeier@memphis.edu>
8
+ License: MIT License
9
+
10
+ Copyright (c) 2025 Nischal Kafle
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "nsEVDx"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+
30
+ Project-URL: Homepage, https://github.com/Nischalcs50/nsEVDx
31
+ Project-URL: Repository, https://github.com/Nischalcs50/nsEVDx
32
+ Project-URL: Documentation, https://github.com/Nischalcs50/nsEVDx/docs
33
+ Keywords: Bayesian inference,Frequentist,Generalised extreme value,Generalised pareto,Frequency analyses,Hydroclimatology
34
+ Requires-Python: >=3.9
35
+ Description-Content-Type: text/markdown
36
+ Requires-Dist: numpy
37
+ Requires-Dist: scipy
38
+ Requires-Dist: matplotlib
39
+ Requires-Dist: seaborn
40
+ Provides-Extra: dev
41
+ Requires-Dist: pytest; extra == "dev"
42
+ Dynamic: author
43
+ Dynamic: requires-python
44
+
45
+ # nsEVDx: A python Library for modelling non-stationary extreme value distributions
46
+
47
+ ![Python](https://img.shields.io/badge/python-3.9%252B-blue) ![License](https://img.shields.io/badge/license-MIT-green)
48
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.15850043.svg)](https://doi.org/10.5281/zenodo.15850043)
49
+
50
+ `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.
51
+
52
+ ## Features
53
+
54
+ - Fits stationary and nonstationary EVDs
55
+ - Supports Frequentist and Bayesian inference
56
+ - Transparent, fully customizable MCMC engine implemented in NumPy
57
+ - Advanced samplers: Metropolis Hasting RandomWalk, Metropolis Adjusted Langevin Algorithm (MALA), and Hamiltonian Monte Carlo (HMC)
58
+ - Support arbitratry covariates in location, scale and shape parameters
59
+ - Integrated diagnostic tools: trace plots, acceptance rates, and bayesian metrics
60
+ - Visualization tool for posterior summaries
61
+ - Lightweight and minimal dependency, only `numpy, scipy, matplotlib, seaborn`
62
+
63
+ ## Implementation
64
+
65
+ 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.
66
+
67
+ 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.
68
+
69
+ 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.
70
+
71
+ ## Installation
72
+
73
+ **For regular users**
74
+
75
+ ``` bash
76
+ pip install nsEVDx
77
+
78
+ # Or clone from GitHub:
79
+ git clone https://github.com/Nischalcs50/nsEVDx
80
+ cd nsEVDx
81
+ pip install .
82
+ ```
83
+
84
+ **For developers/contributors**
85
+
86
+ ``` bash
87
+ git clone https://github.com/Nischalcs50/nsEVDx
88
+ cd nsEVDx
89
+ pip install -e .[dev]
90
+ ```
91
+
92
+ ## Quick Start
93
+
94
+ ``` python
95
+ from nsEVDx import NonStationaryEVD
96
+
97
+ sampler = NonStationaryEVD(...)
98
+ posterior, acc_rate = sampler.MH_RandWalk(...)
99
+ ```
100
+
101
+ ## Documentation
102
+
103
+ See [Documentation](docs/) for full [API](docs/API.md) and usage examples.
104
+
105
+ ## Usage
106
+
107
+ The usage document is available [here](docs/usage.md). For more details, see the usage examples in the Jupyter notebooks [here](examples/).
108
+
109
+ ## Dependencies
110
+
111
+ - numpy
112
+ - scipy
113
+ - matplotlib, seaborn (for plots)
114
+
115
+ ## License
116
+
117
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
118
+
119
+ ## Citation
120
+
121
+ If you use `nsEVDx` in your research, please cite:
122
+
123
+ 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]
124
+
125
+ ## Contributing
126
+
127
+ Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on contributing to this project, and refer to our [Code of Conduct](CODE_OF_CONDUCT.md) to foster an inclusive and respectful community.
128
+
129
+ ## References
130
+
131
+ - Betancourt, M. (2017). A Conceptual Introduction to Hamiltonian Monte Carlo. arXiv: Methodology.
132
+ - Coles, S. (2007). An introduction to statistical modeling of extreme values (4th. printing). Springer. <https://doi.org/10.1007/978-1-4471-3675-0>
133
+ - Gilleland, E. (2025). extRemes: Extreme Value Analysis. <https://doi.org/10.326> 14/CRAN.package.extRemes
134
+ - 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
135
+ - 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
136
+ - IRSN. (2024). NSGEV: Non-Stationary GEV Time Series. <https://github.com> /IRSN/NSGEV/
137
+ - Kafle, N., & Meier, C. (n.d.). Detecting trends in short duration extreme precipitation over SEUS using neighborhood based method. Manuscript in Preparation.
138
+ - 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
139
+ - 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>
140
+ - Paciorek, C. (2016). climextRemes: Tools for Analyzing Climate Extremes. <https://CRAN.R-project.org/package=climextRemes>
141
+ - Robert, C. P., & Casella, G. (2009). Introducing Monte Carlo Methods with R. <https://doi.org/10.1007/978-1-4419-1576-4>
142
+ - 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>
143
+ - Stan development Team. (2023a). CmdStan: The command-line interface to Stan. <https://mc-stan.org/users/interfaces/cmdstan>
144
+ - Stan development Team. (2023b). PyStan: The python interface to Stan. <https://pystan.readthedocs.io/>
nsevdx-0.1.0/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # nsEVDx: A python Library for modelling non-stationary extreme value distributions
2
+
3
+ ![Python](https://img.shields.io/badge/python-3.9%252B-blue) ![License](https://img.shields.io/badge/license-MIT-green)
4
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.15850043.svg)](https://doi.org/10.5281/zenodo.15850043)
5
+
6
+ `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.
7
+
8
+ ## Features
9
+
10
+ - Fits stationary and nonstationary EVDs
11
+ - Supports Frequentist and Bayesian inference
12
+ - Transparent, fully customizable MCMC engine implemented in NumPy
13
+ - Advanced samplers: Metropolis Hasting RandomWalk, Metropolis Adjusted Langevin Algorithm (MALA), and Hamiltonian Monte Carlo (HMC)
14
+ - Support arbitratry covariates in location, scale and shape parameters
15
+ - Integrated diagnostic tools: trace plots, acceptance rates, and bayesian metrics
16
+ - Visualization tool for posterior summaries
17
+ - Lightweight and minimal dependency, only `numpy, scipy, matplotlib, seaborn`
18
+
19
+ ## Implementation
20
+
21
+ 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.
22
+
23
+ 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.
24
+
25
+ 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.
26
+
27
+ ## Installation
28
+
29
+ **For regular users**
30
+
31
+ ``` bash
32
+ pip install nsEVDx
33
+
34
+ # Or clone from GitHub:
35
+ git clone https://github.com/Nischalcs50/nsEVDx
36
+ cd nsEVDx
37
+ pip install .
38
+ ```
39
+
40
+ **For developers/contributors**
41
+
42
+ ``` bash
43
+ git clone https://github.com/Nischalcs50/nsEVDx
44
+ cd nsEVDx
45
+ pip install -e .[dev]
46
+ ```
47
+
48
+ ## Quick Start
49
+
50
+ ``` python
51
+ from nsEVDx import NonStationaryEVD
52
+
53
+ sampler = NonStationaryEVD(...)
54
+ posterior, acc_rate = sampler.MH_RandWalk(...)
55
+ ```
56
+
57
+ ## Documentation
58
+
59
+ See [Documentation](docs/) for full [API](docs/API.md) and usage examples.
60
+
61
+ ## Usage
62
+
63
+ The usage document is available [here](docs/usage.md). For more details, see the usage examples in the Jupyter notebooks [here](examples/).
64
+
65
+ ## Dependencies
66
+
67
+ - numpy
68
+ - scipy
69
+ - matplotlib, seaborn (for plots)
70
+
71
+ ## License
72
+
73
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
74
+
75
+ ## Citation
76
+
77
+ If you use `nsEVDx` in your research, please cite:
78
+
79
+ 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]
80
+
81
+ ## Contributing
82
+
83
+ Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on contributing to this project, and refer to our [Code of Conduct](CODE_OF_CONDUCT.md) to foster an inclusive and respectful community.
84
+
85
+ ## References
86
+
87
+ - Betancourt, M. (2017). A Conceptual Introduction to Hamiltonian Monte Carlo. arXiv: Methodology.
88
+ - Coles, S. (2007). An introduction to statistical modeling of extreme values (4th. printing). Springer. <https://doi.org/10.1007/978-1-4471-3675-0>
89
+ - Gilleland, E. (2025). extRemes: Extreme Value Analysis. <https://doi.org/10.326> 14/CRAN.package.extRemes
90
+ - 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
91
+ - 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
92
+ - IRSN. (2024). NSGEV: Non-Stationary GEV Time Series. <https://github.com> /IRSN/NSGEV/
93
+ - Kafle, N., & Meier, C. (n.d.). Detecting trends in short duration extreme precipitation over SEUS using neighborhood based method. Manuscript in Preparation.
94
+ - 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
95
+ - 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>
96
+ - Paciorek, C. (2016). climextRemes: Tools for Analyzing Climate Extremes. <https://CRAN.R-project.org/package=climextRemes>
97
+ - Robert, C. P., & Casella, G. (2009). Introducing Monte Carlo Methods with R. <https://doi.org/10.1007/978-1-4419-1576-4>
98
+ - 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>
99
+ - Stan development Team. (2023a). CmdStan: The command-line interface to Stan. <https://mc-stan.org/users/interfaces/cmdstan>
100
+ - Stan development Team. (2023b). PyStan: The python interface to Stan. <https://pystan.readthedocs.io/>
@@ -0,0 +1,34 @@
1
+ from .evd_model import NonStationaryEVD
2
+ from .utils import (
3
+ neg_log_likelihood,
4
+ neg_log_likelihood_ns,
5
+ EVD_parsViaMLE,
6
+ comb,
7
+ l_moments,
8
+ GPD_parsViaLM,
9
+ GEV_parsViaLM,
10
+ plot_trace,
11
+ plot_posterior,
12
+ bayesian_metrics,
13
+ gelman_rubin
14
+ )
15
+
16
+ __all__ = [
17
+ "NonStationaryEVD",
18
+ "neg_log_likelihood",
19
+ "neg_log_likelihood_ns",
20
+ "EVD_parsViaMLE",
21
+ "comb",
22
+ "l_moments",
23
+ "GPD_parsViaLM",
24
+ "GEV_parsViaLM",
25
+ "plot_trace",
26
+ "plot_posterior",
27
+ "bayesian_metrics",
28
+ "gelman_rubin"
29
+ ]
30
+
31
+
32
+ from ._version import get_versions
33
+ __version__ = get_versions()["version"]
34
+ del get_versions
@@ -0,0 +1,2 @@
1
+ def get_versions():
2
+ return {"version": "0.1.0"}