lmo


Namelmo JSON
Version 0.14.2 PyPI version JSON
download
home_pagehttps://jorenham.github.io/Lmo/
SummaryL-Moments for robust statistics & inference.
upload_time2024-08-27 06:59:26
maintainerNone
docs_urlNone
authorJoren Hammudoglu
requires_python<4.0.0,>=3.10.1
licenseBSD-3-Clause
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <!--overview-start-->

# Lmo - Trimmed L-moments and L-comoments

![Lmo - License][IMG-BSD]
[![Lmo - PyPI][IMG-PYPI]](https://pypi.org/project/Lmo/)
[![Lmo - Versions][IMG-VER]](https://github.com/jorenham/Lmo)
![Lmo - CI][IMG-CI]
[![Lmo - Pre-commit][IMG-PC]](https://github.com/pre-commit/pre-commit)
[![Lmo - Ruff][IMG-RUFF]](https://github.com/astral-sh/ruff)
[![Lmo - BassedPyright][IMG-BPR]](https://detachhead.github.io/basedpyright)

[IMG-CI]: https://img.shields.io/github/actions/workflow/status/jorenham/Lmo/ci.yml?branch=master
[IMG-BSD]: https://img.shields.io/github/license/jorenham/Lmo
[IMG-PYPI]: https://img.shields.io/pypi/v/Lmo
[IMG-VER]: https://img.shields.io/pypi/pyversions/Lmo
[IMG-pC]: https://img.shields.io/badge/pre--commit-enabled-orange?logo=pre-commit
[IMG-RUFF]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
[IMG-BPR]: https://img.shields.io/badge/basedpyright-checked-42b983

Unlike the legacy
[product-moments](https://wikipedia.org/wiki/Moment_(mathematics)), the
[*L-moments*](https://wikipedia.org/wiki/L-moment) **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-*co*moments, 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-*co*moment 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](https://jorenham.github.io/lmo/), 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](https://wikipedia.org/wiki/Cauchy_distribution), 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:

```pycon
>>> 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:

```pycon
>>> from scipy.stats import cauchy
>>> cauchy.l_moment([1, 2], trim=(1, 1))
array([0.        , 0.69782723])
```

---

See the [documentation](https://jorenham.github.io/lmo/) 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](https://pypi.org/project/lmo/), so you can do something like:

```shell
pip install lmo
```

### Dependencies

These are automatically installed by your package manager when installing Lmo.

| Package      | Supported versions |
| ------------ | ------------------ |
| [Python][PY] | `>=3.10`           |
| [NumPy][NP]  | `>=1.23`           |
| [SciPy][SP]  | `>=1.9`            |

Additionally, Lmo supports the following optional packages:

| Package      | Supported versions | Installation              |
| ------------ | ------------------ | ------------------------- |
| [Pandas][PD] | `>=1.5`            | `pip install Lmo[pandas]` |

See [SPEC 0][SPEC0] for more information.

[PY]: https://github.com/python/cpython
[NP]: https://github.com/numpy/numpy
[SP]: https://github.com/scipy/scipy
[PD]: https://github.com/pandas-dev/pandas
[SPEC0]: https://scientific-python.org/specs/spec-0000/

## Foundational Literature

- [*J.R.M. Hosking* (1990) &ndash; L-moments: Analysis and Estimation of
  Distributions using Linear Combinations of Order Statistics
  ](https://doi.org/10.1111/j.2517-6161.1990.tb01775.x)
- [*E.A.H. Elamir & A.H. Seheult* (2003) &ndash; Trimmed L-moments
  ](https://doi.org/10.1016/S0167-9473(02)00250-5)
- [*J.R.M. Hosking* (2007) &ndash; Some theory and practical uses of trimmed
  L-moments](https://doi.org/10.1016/j.jspi.2006.12.002)
- [*R. Serfling & P. Xiao* (2007) &ndash; A contribution to multivariate
  L-moments: L-comoment matrices](https://doi.org/10.1016/j.jmva.2007.01.008)

<!--overview-end-->

            

Raw data

            {
    "_id": null,
    "home_page": "https://jorenham.github.io/Lmo/",
    "name": "lmo",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0.0,>=3.10.1",
    "maintainer_email": null,
    "keywords": null,
    "author": "Joren Hammudoglu",
    "author_email": "jhammudoglu@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/33/58/2185023194adc988d70cca4e8628e50f2e6e85fc60c537d1dede99790470/lmo-0.14.2.tar.gz",
    "platform": null,
    "description": "<!--overview-start-->\n\n# Lmo - Trimmed L-moments and L-comoments\n\n![Lmo - License][IMG-BSD]\n[![Lmo - PyPI][IMG-PYPI]](https://pypi.org/project/Lmo/)\n[![Lmo - Versions][IMG-VER]](https://github.com/jorenham/Lmo)\n![Lmo - CI][IMG-CI]\n[![Lmo - Pre-commit][IMG-PC]](https://github.com/pre-commit/pre-commit)\n[![Lmo - Ruff][IMG-RUFF]](https://github.com/astral-sh/ruff)\n[![Lmo - BassedPyright][IMG-BPR]](https://detachhead.github.io/basedpyright)\n\n[IMG-CI]: https://img.shields.io/github/actions/workflow/status/jorenham/Lmo/ci.yml?branch=master\n[IMG-BSD]: https://img.shields.io/github/license/jorenham/Lmo\n[IMG-PYPI]: https://img.shields.io/pypi/v/Lmo\n[IMG-VER]: https://img.shields.io/pypi/pyversions/Lmo\n[IMG-pC]: https://img.shields.io/badge/pre--commit-enabled-orange?logo=pre-commit\n[IMG-RUFF]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json\n[IMG-BPR]: https://img.shields.io/badge/basedpyright-checked-42b983\n\nUnlike the legacy\n[product-moments](https://wikipedia.org/wiki/Moment_(mathematics)), the\n[*L-moments*](https://wikipedia.org/wiki/L-moment) **uniquely describe** a\nprobability distribution, and are more robust and efficient.\n\nThe \"L\" stands for Linear; it is a linear combination of order statistics.\nSo Lmo is as fast as sorting your samples (in terms of time-complexity).\n\n## Key Features\n\n- Calculates trimmed L-moments and L-*co*moments, from samples or any\n  `scipy.stats` distribution.\n- Full support for trimmed L-moment (TL-moments), e.g.\n  `lmo.l_moment(..., trim=(1/137, 3.1416))`.\n- Generalized Method of L-moments: robust distribution fitting that beats MLE.\n- Fast estimation of L-*co*moment matrices from your multidimensional data\n  or multivariate distribution.\n- Goodness-of-fit test, using L-moment or L-moment ratio's.\n- Exact (co)variance structure of the sample- and population L-moments.\n- Theoretical & empirical influence functions of L-moments & L-ratio's.\n- Complete [docs](https://jorenham.github.io/lmo/), including detailed API\nreference with usage examples and with mathematical $\\TeX$ definitions.\n- Clean Pythonic syntax for ease of use.\n- Vectorized functions for very fast fitting.\n- Fully typed, tested, and tickled.\n- Optional Pandas integration.\n\n## Quick example\n\nEven if your data is pathological like\n[Cauchy](https://wikipedia.org/wiki/Cauchy_distribution), and the L-moments\nare not defined, the trimmed L-moments (TL-moments) can be used instead.\nLet's calculate the TL-location and TL-scale of a small amount of samples:\n\n```pycon\n>>> import numpy as np\n>>> import lmo\n>>> rng = np.random.default_rng(1980)\n>>> x = rng.standard_cauchy(96)  # pickle me, Lmo\n>>> lmo.l_moment(x, [1, 2], trim=(1, 1)).\narray([-0.17937038,  0.68287665])\n```\n\nNow compare with the theoretical standard Cauchy TL-moments:\n\n```pycon\n>>> from scipy.stats import cauchy\n>>> cauchy.l_moment([1, 2], trim=(1, 1))\narray([0.        , 0.69782723])\n```\n\n---\n\nSee the [documentation](https://jorenham.github.io/lmo/) for more examples and\nthe API reference.\n\n## Roadmap\n\n- Automatic trim-length selection.\n- Plotting utilities (deps optional), e.g. for L-moment ratio diagrams.\n\n## Installation\n\nLmo is on [PyPI](https://pypi.org/project/lmo/), so you can do something like:\n\n```shell\npip install lmo\n```\n\n### Dependencies\n\nThese are automatically installed by your package manager when installing Lmo.\n\n| Package      | Supported versions |\n| ------------ | ------------------ |\n| [Python][PY] | `>=3.10`           |\n| [NumPy][NP]  | `>=1.23`           |\n| [SciPy][SP]  | `>=1.9`            |\n\nAdditionally, Lmo supports the following optional packages:\n\n| Package      | Supported versions | Installation              |\n| ------------ | ------------------ | ------------------------- |\n| [Pandas][PD] | `>=1.5`            | `pip install Lmo[pandas]` |\n\nSee [SPEC 0][SPEC0] for more information.\n\n[PY]: https://github.com/python/cpython\n[NP]: https://github.com/numpy/numpy\n[SP]: https://github.com/scipy/scipy\n[PD]: https://github.com/pandas-dev/pandas\n[SPEC0]: https://scientific-python.org/specs/spec-0000/\n\n## Foundational Literature\n\n- [*J.R.M. Hosking* (1990) &ndash; L-moments: Analysis and Estimation of\n  Distributions using Linear Combinations of Order Statistics\n  ](https://doi.org/10.1111/j.2517-6161.1990.tb01775.x)\n- [*E.A.H. Elamir & A.H. Seheult* (2003) &ndash; Trimmed L-moments\n  ](https://doi.org/10.1016/S0167-9473(02)00250-5)\n- [*J.R.M. Hosking* (2007) &ndash; Some theory and practical uses of trimmed\n  L-moments](https://doi.org/10.1016/j.jspi.2006.12.002)\n- [*R. Ser\ufb02ing & P. Xiao* (2007) &ndash; A contribution to multivariate\n  L-moments: L-comoment matrices](https://doi.org/10.1016/j.jmva.2007.01.008)\n\n<!--overview-end-->\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "L-Moments for robust statistics & inference.",
    "version": "0.14.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/jorenham/Lmo/issues",
        "Documentation": "https://jorenham.github.io/Lmo/",
        "Homepage": "https://jorenham.github.io/Lmo/",
        "Repository": "https://github.com/jorenham/Lmo/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f4f19a9b445a949d06a5afd56c1a438bc68180008c6621bb4527b32f9747603a",
                "md5": "656391d2895e0762008725b7cd6b920f",
                "sha256": "92887eadcfee1f22d7b51d79a4a6d80464a185081fe7952d1495fc6232214806"
            },
            "downloads": -1,
            "filename": "lmo-0.14.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "656391d2895e0762008725b7cd6b920f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0.0,>=3.10.1",
            "size": 115935,
            "upload_time": "2024-08-27T06:59:24",
            "upload_time_iso_8601": "2024-08-27T06:59:24.466007Z",
            "url": "https://files.pythonhosted.org/packages/f4/f1/9a9b445a949d06a5afd56c1a438bc68180008c6621bb4527b32f9747603a/lmo-0.14.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "33582185023194adc988d70cca4e8628e50f2e6e85fc60c537d1dede99790470",
                "md5": "ec8d3f9682ddc77f8ea90012dce669b5",
                "sha256": "7ae9352b70d1f6c8f86dfb433a36269b2ee7187157b06dad8be03d973e2bb56d"
            },
            "downloads": -1,
            "filename": "lmo-0.14.2.tar.gz",
            "has_sig": false,
            "md5_digest": "ec8d3f9682ddc77f8ea90012dce669b5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0.0,>=3.10.1",
            "size": 100884,
            "upload_time": "2024-08-27T06:59:26",
            "upload_time_iso_8601": "2024-08-27T06:59:26.385380Z",
            "url": "https://files.pythonhosted.org/packages/33/58/2185023194adc988d70cca4e8628e50f2e6e85fc60c537d1dede99790470/lmo-0.14.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-27 06:59:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jorenham",
    "github_project": "Lmo",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "lmo"
}
        
Elapsed time: 0.86396s