fitdistcp
fitdistcp is a free Python package for fitting statistical models using calibrating priors, with the goal of making reliable predictions. Install using >pip install fitdistcp.
fitdistcp implements the method developed in Reducing Reliability Bias in Assessments of Extreme Weather Risk using Calibrating Priors, S. Jewson, T. Sweeting and L. Jewson (2024): https://doi.org/10.5194/ascmo-11-1-2025.
More information and examples are available at https://www.fitdistcp.info, including the equivalent (more comprehensive) R package.
Development of this package was funded by the Lighthill Risk Network: https://lighthillrisknetwork.org.
Example: Fitting a GEV distribution
import numpy as np
import scipy.stats
import matplotlib.pyplot as plt
import fitdistcp.genextreme
x = scipy.stats.genextreme.rvs(0, size=20) # make some example training data
p = np.arange(0.001,0.999,0.001) # define the probabilities at which we wish to calculate the quantiles
q = fitdistcp.genextreme.ppf(x,p) # this command calculates two sets of predictive quantiles for the GEV,
# one based on maxlik, and one that includes parameter uncertainty based on a calibrating prior
print(q['ml_params']) # have a look at the maxlik parameters
plt.plot(q['ml_quantiles'],p, label='ML') # plot the maxlik quantiles
plt.plot(q['cp_quantiles'],p,color='red', label='CP') # plot the quantiles that include parameter uncertainty
plt.legend()
plt.show()
Models
The following models are currently supported. Let us know if you have any suggestions for other models to include.
- expon: Exponential distribution
- gamma: Gamma distribution
- genextreme: Generalised Extreme Value (GEV) distribution
- genextreme_p1 & genextreme_p12: Generalised Extreme Value (GEV) distribution, with 1 predictor, 2 predictors
- genpareto: Generalised Pareto distribution
- gumbel: Gumbel distribution
- lnorm: Lognormal distribution
- norm: Normal distribution
- weibull: Weibull distribution
Methods
Four methods are provided for each model: ppf(x) (quantiles, 'percentage point function'), rvs(n, x) (random variates), pdf(x) and cdf(x), where x is the data to fit. To use, e.g. ppf for the normal distribution, import fitdistcp.norm and call fitdistcp.norm.ppf(x). To test the methods use e.g. fitdistcp.norm.reltest(). Reltests (reliability tests) are used to test the reliability of quantile calculations for making predictions.
Metadata
Release files for fitdistcp 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fitdistcp-0.1.1.tar.gz | 82.1 kB | Without provenance | Details for fitdistcp-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fitdistcp-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for fitdistcp-0.1.1-py3-none-any.whl |
Total release size: 186.2 kB
Release files / fitdistcp-0.1.1.tar.gz
| Download URL | fitdistcp-0.1.1.tar.gz |
|---|---|
| Size | 82.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
455ef8fee442d9d6223c69c04f4515c5243dccf5d8e7a63c7022201883329555
|
|
BLAKE2b-256 checksum How to use checksums |
1d487172e5df7dc429e17703b6eb2c7f000fac7f71d47b80c1dff8b1ff9a0ff5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Release files / fitdistcp-0.1.1-py3-none-any.whl
| Download URL | fitdistcp-0.1.1-py3-none-any.whl |
|---|---|
| Size | 104.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
276b9b5d823da0361bdbf0384798d7fa55bc2b409dae3b68e3b4169bf5629894
|
|
BLAKE2b-256 checksum How to use checksums |
872f48572e135e629bf229449837d89d3aba8a42099b0ec2880ebbd20a7ba097
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Security for fitdistcp 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.