Skip to main content

Lmo - Trimmed L-moments and L-comoments

Lmo - License Lmo - PyPI Lmo - Versions Lmo - CI Lmo - Pre-commit Lmo - Ruff Lmo - BassedPyright

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

Release files for lmo 0.14.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lmo 0.14.2
File Size Uploaded
lmo-0.14.2.tar.gz 100.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lmo 0.14.2
File Interpreter ABI Platform
lmo-0.14.2-py3-none-any.whl Python 3 none any Details

Total release size: 216.8 kB

Release files / lmo-0.14.2.tar.gz

Download URL lmo-0.14.2.tar.gz
Size 100.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7ae9352b70d1f6c8f86dfb433a36269b2ee7187157b06dad8be03d973e2bb56d
BLAKE2b-256 checksum
How to use checksums
33582185023194adc988d70cca4e8628e50f2e6e85fc60c537d1dede99790470
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.5 Linux/6.9.3-76060903-generic

Release files / lmo-0.14.2-py3-none-any.whl

Download URL lmo-0.14.2-py3-none-any.whl
Size 115.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92887eadcfee1f22d7b51d79a4a6d80464a185081fe7952d1495fc6232214806
BLAKE2b-256 checksum
How to use checksums
f4f19a9b445a949d06a5afd56c1a438bc68180008c6621bb4527b32f9747603a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.5 Linux/6.9.3-76060903-generic

Release history Release notifications | RSS feed

This release

0.14.2 This release

2 release files

0.14.1

2 release files

0.14.0

2 release files

0.13.2

2 release files

0.13.1

2 release files

0.13.0

2 release files

0.12.1

2 release files

0.11.3

2 release files

0.11.0

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page