L-Moments for robust statistics.
Project description
Lmo - Trimmed L-moments and L-comoments
Is your tail too heavy?
Can't find a moment?
Are the swans black?
The distribution pathological?
... then look no further: Lmo's got you covered!
Uniform or multi-dimensional, Lmo can summarize it all with one quick glance!
Unlike the legacy moments, 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 data or a distribution function.
- Complete support for trimmed L-moment (TL-moments):
lmo.l_moment(..., trim=(1 / 137, 3.1416))
. - Fast estimation of L-comoment matrices from your multidimensional data.
- A fully non-parametric
scipy.stats
-like distribution,lmo.l_rv
. It's very efficient, robust, fast, and requires only some L-mo's! - Exact (co)variance structure of the L-moment estimates.
- Complete docs, including overly complex $\TeX$ spaghetti equations.
- Clean Pythonic syntax for ease of use.
- Vectorized functions for very fast fitting.
- Fully typed, tested, and tickled.
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:
>>> import numpy as np
>>> import lmo
>>> rng = np.random.default_rng(1980)
>>> x = rng.standard_cauchy(96) # pickle me, Lmo
>>> x.mean(), x.std() # don't try this at home
(-1.7113440959133905, 19.573507308373326)
>>> lmo.l_loc(x, trim=(1, 1)), lmo.l_scale(x, (1, 1))
(-0.17937038148581977, 0.6828766469913776)
For reference; the theoretical TL-location and TL-scale of the standard Cauchy distribution are $\lambda^{(1, 1)}_{1} = 0$ and $\lambda^{(1, 1)}_2 \approx 0.7$ (Elamir & Seheult, 2003).
See the documentation for more examples and the API reference.
Roadmap:
- Add methods to all
scipy.stats
univariate distributions, for finding the theoretical/population L-mo's. - Robust distribution fitting, using the (generalized) method of L-moments.
- Theoretical L-moment variance structure calculation.
- A generic goodness-of-fit test.
- Automatic trim-length selection.
- Plotting utilities (deps optional), e.g. for L-moment ratio diagrams.
- Extended multivariate support, e.g. theoretical L-comoments, and L-regression.
Installation
Lmo is on PyPI, so you can do something like:
pip install lmo
Dependencies
python >= 3.10
numpy >= 1.22
scipy >= 1.9
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
- E.A.H. Elamir & A.H. Seheult (2004) – Exact variance structure of sample 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
- W.H. Asquith (2011) – Univariate Distributional Analysis with L-moment Statistics
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.9.0.tar.gz
.
File metadata
- Download URL: lmo-0.9.0.tar.gz
- Upload date:
- Size: 36.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.2 Linux/6.4.6-76060406-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc803d325a6a94a0675166ab02dcc4bcb9ba0b9fb78a1ddd549734a815ae3058 |
|
MD5 | c47d326374332a446d43de680be68d6d |
|
BLAKE2b-256 | c24a98a3d3c554bd23ffc2f4925cf7fae10b27787a307d494a598a574c81d953 |
File details
Details for the file lmo-0.9.0-py3-none-any.whl
.
File metadata
- Download URL: lmo-0.9.0-py3-none-any.whl
- Upload date:
- Size: 40.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.2 Linux/6.4.6-76060406-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41c9113f48f959a770393feb302568992eef9e7dcb93565717575d8d9d5a376a |
|
MD5 | 7ede1591c6e42b798b341491522d4294 |
|
BLAKE2b-256 | 4017f5efb1b26b1e8838c8c63e6e56d5742656c1a3c9cd6c76c202df0dcfec4c |