Skip to main content

L-Moments for robust statistics.

Project description

jorenham/lmo

Lmo - Trimmed L-moments and L-comoments

GitHub Workflow Status (with branch) PyPI versions license


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 samples or any scipy.stats distribution.
  • Full support for trimmed L-moment (TL-moments), e.g. lmo.l_moment(..., trim=(1/137, 3.1416)).
  • Method of L-moments for robust distribution fitting.
  • Fast estimation of L-comoment matrices from your multidimensional data.
  • Goodness-of-fit test, using L-moment or L-moment ratio's.
  • Non-parametric estimation of continuous distributions with lmo.l_rv_nonparametric
  • 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.

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.
  • 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

Project details


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.10.0.tar.gz (56.2 kB view details)

Uploaded Source

Built Distribution

lmo-0.10.0-py3-none-any.whl (60.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lmo-0.10.0.tar.gz
  • Upload date:
  • Size: 56.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/6.4.6-76060406-generic

File hashes

Hashes for lmo-0.10.0.tar.gz
Algorithm Hash digest
SHA256 60ff84887b12fdcb2eee0a36a57a5944da04687005db946225bcf2408983af0e
MD5 1191e462c179457b6567474b85169bb1
BLAKE2b-256 68f75c1b2e98e968c6889fafa78f4dc57213c7b4c7297611d6bdab6e8ac33fe0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lmo-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 60.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/6.4.6-76060406-generic

File hashes

Hashes for lmo-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eb1de8cd288e19985a03a25939f6cc40fba6378fc8c56b1c1b83d48fc8a6f92a
MD5 0c2fb4b9dd4a423f5b0233298af432b1
BLAKE2b-256 032a1e040fd026b6850e58e8595983d976276e57475db72b0753afe146bb382b

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