Skip to main content

L-Moments for robust statistics & inference.

Project description

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lmo-0.14.1.tar.gz (94.6 kB view details)

Uploaded Source

Built Distribution

lmo-0.14.1-py3-none-any.whl (101.6 kB view details)

Uploaded Python 3

File details

Details for the file lmo-0.14.1.tar.gz.

File metadata

  • Download URL: lmo-0.14.1.tar.gz
  • Upload date:
  • Size: 94.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Linux/6.9.3-76060903-generic

File hashes

Hashes for lmo-0.14.1.tar.gz
Algorithm Hash digest
SHA256 52419d982d8b11e64629dc1e8125c5b6fe1ba3188655a54145d4ba3db49bece9
MD5 1ef263c44958913e2fa7c80fce3a5407
BLAKE2b-256 8b98aa78e9c46a62e47f00a411453f69660ab323a545849a97d6c2c95ff8e899

See more details on using hashes here.

File details

Details for the file lmo-0.14.1-py3-none-any.whl.

File metadata

  • Download URL: lmo-0.14.1-py3-none-any.whl
  • Upload date:
  • Size: 101.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Linux/6.9.3-76060903-generic

File hashes

Hashes for lmo-0.14.1-py3-none-any.whl
Algorithm Hash digest
SHA256 89330c291597a3229a68daf4bb9c651e590cebf216307e4770ad9ac0f58abd94
MD5 68ef49c2429013ec6b6cef9b6d31f3c1
BLAKE2b-256 0009baabb30e57e72866ed972d271b4d1dea52e0c19f455cfdd9575091673da2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page