L-moments UQ — Python port
A Python port of the L-UQ MATLAB toolbox one directory up: distribution-independent uncertainty quantification from scarce samples, including data with extremes, using L-moments. Same method, same 9 supported distribution families, plus an interactive Streamlit UI.
Validation. Every parameter-estimation formula and
distribution-parameterization/sign convention is validated against
known scipy.stats ground truth — see
tests/test_lmoments.py (30 tests). In
addition, this port and the MATLAB implementation have been verified
equivalent: on fixed reference samples, MATLAB's lmom,
Parameter_estimation, and CDF_l reproduce this package's
L-moments, parameter vectors, and fitted CDF values to within 1e-8
(run tests/octave_verify.m under GNU
Octave, or the MATLAB suite tests/test_uq_matlab.m — both pass, the
latter under MATLAB R2026a). On the same samples the package agrees
with R's lmom to machine precision wherever the closed forms
coincide.
Install
cd python
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[ui,dev]"
Run the tests
pytest tests/ -v
Run the illustrative example
python demo_example.py --no-show # saves demo_example_output.png
Run the interactive UI
streamlit run app.py
Lets you paste in a sample (or generate a synthetic scarce+extreme one), see its L-moments and the ranked distribution-family match, pick a family to fit, and view the PDF/CDF fit against the sample compared with a conventional-moment (MLE) fit of the same family, plus Jensen-Shannon divergence numbers quantifying the difference.
Install
pip install lmoments-uq # distribution name (hyphen)
The import namespace is lmoments_uq (underscore), distinct from the
unrelated lmoments / lmoments3 packages on PyPI.
API
from lmoments_uq import identify_dist, parameter_estimation, pdf_l, cdf_l, random_l, js_div
result = identify_dist(x) # {'best', 'ranking', 'L_sample'}
params = parameter_estimation(x, result['best'], *result['L_sample'])
pdf_vals = pdf_l(xgrid, result['best'], params)
# uncertainty-aware identification (bootstrap selection frequencies)
from lmoments_uq import identify_dist_bootstrap
boot = identify_dist_bootstrap(x) # {'best','selection_frequencies','status',...}
Differences from the MATLAB version
identify_distreturns the full ranked distance to all 9 candidate families (result['ranking']), not just the single closest match — a strict addition, useful for the UI's ranking table.parameter_identify(x, k)genuinely fits the top-kcandidates; the MATLAB version'sKargument silently breaks forK>1becauseIdentify_dist.mnever actually returns more than one candidate.- The Gamma distribution's location shift is applied consistently in both
pdf_landcdf_lin both implementations (MATLAB'sCDF_l.mhistorically omitted it; fixed as of the SoftwareX/JSS submission preparation). kl_div(p, q)returnsinfwhenphas mass in a bin whereqhas none (the mathematically correct value); MATLAB'sKLDiv.mdrops such bins and can return a finite — even negative — divergence there. This cannot affectjs_div, whose mixture term is positive whereverpis, andjs_divwas verified to machine precision againstscipy.spatial.distance.jensenshannon(see the divergence tests).weibulis supported inparameter_estimation/pdf_l/cdf_l/random_lfor completeness, but — matching the MATLAB version — is not one of the familiesidentify_distwill pick automatically.
Known limitations (inherited from the method/toolbox)
- Weibull is not offered for automatic identification (see above).
- Gumbel is the k=0 special case of the GEV curve, and Uniform is the k=1
boundary case of the GP curve, on the L-moment ratio diagram; for
samples near those special cases,
identify_distcan pick either the special-case family or its generalizing family. This is a property of the diagram itself, not a bug (seetests/test_lmoments.pyfor how this is handled in testing).
Metadata
Release files for lmoments-uq 1.2.0
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 |
|---|---|---|---|---|
| lmoments_uq-1.2.0.tar.gz | 19.6 kB | Without provenance | Details for lmoments_uq-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lmoments_uq-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for lmoments_uq-1.2.0-py3-none-any.whl |
Total release size: 32.9 kB
Release files / lmoments_uq-1.2.0.tar.gz
| Download URL | lmoments_uq-1.2.0.tar.gz |
|---|---|
| Size | 19.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2bde39a8c7b36579e78d70cd77c638af016af36959b34442891bca7b918e59a4
|
|
BLAKE2b-256 checksum How to use checksums |
2fa16e5386e4dcf7b3f5b57a956735e5eb696eb69123606f2ebc3c9ff22ae000
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.5
|
Release files / lmoments_uq-1.2.0-py3-none-any.whl
| Download URL | lmoments_uq-1.2.0-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
15b85999642f2c7c21c5aa5d5ed0f7c138f9f0e8519924f3caef35e96f151f32
|
|
BLAKE2b-256 checksum How to use checksums |
30302a536062a5fe6b3fe49e22f02a3a899196a97bac370c4b127cba697e6b91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.5
|
Security for lmoments-uq 1.2.0
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.