L-Moments for robust statistics & inference.
Project description
Lmo - Trimmed L-moments and L-comoments
Unlike the legacy product-moments, the L-moments uniquely describe a probability distribution, and are more robust and efficient.
The "L" stands for Linear; it is a linear combination of order statistics. So Lmo is as fast as sorting your samples (in terms of time-complexity).
Key Features
- Calculates trimmed L-moments and L-comoments, from samples or any
scipy.stats
distribution. - Full support for trimmed L-moment (TL-moments), e.g.
lmo.l_moment(..., trim=(1/137, 3.1416))
. - Generalized Method of L-moments: robust distribution fitting that beats MLE.
- Fast estimation of L-comoment matrices from your multidimensional data or multivariate distribution.
- Goodness-of-fit test, using L-moment or L-moment ratio's.
- Exact (co)variance structure of the sample- and population L-moments.
- Theoretical & empirical influence functions of L-moments & L-ratio's.
- Complete docs, including detailed API reference with usage examples and with mathematical $\TeX$ definitions.
- Clean Pythonic syntax for ease of use.
- Vectorized functions for very fast fitting.
- Fully typed, tested, and tickled.
- Optional Pandas integration.
Quick example
Even if your data is pathological like Cauchy, and the L-moments are not defined, the trimmed L-moments (TL-moments) can be used instead. Let's calculate the TL-location and TL-scale of a small amount of samples:
>>> import numpy as np
>>> import lmo
>>> rng = np.random.default_rng(1980)
>>> x = rng.standard_cauchy(96) # pickle me, Lmo
>>> lmo.l_moment(x, [1, 2], trim=(1, 1)).
array([-0.17937038, 0.68287665])
Now compare with the theoretical standard Cauchy TL-moments:
>>> from scipy.stats import cauchy
>>> cauchy.l_moment([1, 2], trim=(1, 1))
array([0. , 0.69782723])
See the documentation for more examples and the API reference.
Roadmap
- Automatic trim-length selection.
- Plotting utilities (deps optional), e.g. for L-moment ratio diagrams.
Installation
Lmo is on PyPI, so you can do something like:
pip install lmo
Dependencies
These are automatically installed by your package manager when installing Lmo.
Package | Supported versions |
---|---|
Python | >=3.10 |
NumPy | >=1.23 |
SciPy | >=1.9 |
Additionally, Lmo supports the following optional packages:
Package | Supported versions | Installation |
---|---|---|
Pandas | >=1.5 |
pip install Lmo[pandas] |
See SPEC 0 for more information.
Foundational Literature
- J.R.M. Hosking (1990) – L-moments: Analysis and Estimation of Distributions using Linear Combinations of Order Statistics
- E.A.H. Elamir & A.H. Seheult (2003) – Trimmed L-moments
- J.R.M. Hosking (2007) – Some theory and practical uses of trimmed L-moments
- R. Serfling & P. Xiao (2007) – A contribution to multivariate L-moments: L-comoment matrices
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file lmo-0.13.2.tar.gz
.
File metadata
- Download URL: lmo-0.13.2.tar.gz
- Upload date:
- Size: 92.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.0-76060800daily20240311-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c7cd3311f07c8db7218d07c9133e4a6bb0758cb08879db50af0e524f6ced505 |
|
MD5 | ffc81ac5a36b6d22646a0217f3109823 |
|
BLAKE2b-256 | 4966471f78af910b9d4cee7a75946319d94042119fda0fdef5ed9ffe92896e9f |
File details
Details for the file lmo-0.13.2-py3-none-any.whl
.
File metadata
- Download URL: lmo-0.13.2-py3-none-any.whl
- Upload date:
- Size: 98.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.0-76060800daily20240311-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13e98b83ed49847a897080b37016732dd4bdb0322230fc6f54df2276edb6e0e0 |
|
MD5 | 63b41d2945fd76fb196d03d8dd43601d |
|
BLAKE2b-256 | 10ffea8479c43785c66d42255c1b42a8cee52f329b0c109766677ef9fee0fb1d |