Skip to content

Commit

Permalink
Merge pull request #307 from jorenham/know-lmoments
Browse files Browse the repository at this point in the history
Exact L-moments of several distributions
  • Loading branch information
jorenham authored Aug 27, 2024
2 parents 4e95619 + 6211a1c commit bcf87d2
Show file tree
Hide file tree
Showing 23 changed files with 1,016 additions and 500 deletions.
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 79

# 2 space indentation
[{*.bib, *.json,*.jsonc,*.yaml,*.yml}]
Expand Down
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"davidanson.vscode-markdownlint",
"detachhead.basedpyright",
"editorconfig.editorconfig",
"ms-python.python"
"ms-python.python",
"notzaki.pandocciter"
],
"unwantedRecommendations": [
"ms-pyright.pyright",
Expand Down
20 changes: 19 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
{}
{
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.rulers": [79, 130]
},
"[bibtex]": {
"editor.rulers": []
},
"[markdown]": {
"editor.rulers": [80]
},
"[markdown_latex_combined]": {
"editor.rulers": [80]
},
"markdown.extension.completion.root": "docs",
"PandocCiter.DefaultBib": "docs/refs.bib",
"PandocCiter.DefaultBibs": ["docs"],
"python.testing.pytestEnabled": true
}
40 changes: 28 additions & 12 deletions docs/api/distributions.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
# Probability Distributions

<!-- TODO: custom listing -->

::: lmo.distributions
options:
heading_level: 2

## `scipy.stats` integration

<!-- TODO: Describe this -->
<!-- TODO: Short example -->

::: lmo.contrib.scipy_stats
::: lmo.contrib.scipy_stats.l_rv_generic
options:
show_bases: false
show_root_full_path: false
show_root_members_full_path: false

## Parametric

::: lmo.distributions.kumaraswamy
options:
show_symbol_type_heading: false
show_labels: false
::: lmo.distributions.wakeby
options:
show_symbol_type_heading: false
show_labels: false
::: lmo.distributions.genlambda
options:
show_symbol_type_heading: false
show_labels: false

## Nonparametric

::: lmo.distributions.l_poly
options:
heading_level: 3
show_root_heading: false
show_root_toc_entry: false
members:
- l_rv_generic
group_by_category: false
show_labels: false
filters:
- "!^(a|b|random_state)$"
27 changes: 16 additions & 11 deletions docs/distributions.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---
hide:
- navigation
---

<!-- markdownlint-disable MD051 MD052 -->
# L-moments of common probability distributions
# Exact L-moments of probability distributions

This page lists theoretical L-moments [@hosking1990] of popular probability
distributions.
Expand Down Expand Up @@ -33,14 +38,14 @@ Numerical calculation of these L-statistics using [`scipy.stats`][scipy.stats]
distributions, refer to
[`rv_continuous.l_stats`][lmo.contrib.scipy_stats.l_rv_generic.l_stats].

For direct calculation of the L-stats from a CDF or PPF, see
[`l_stats_from_cdf`][lmo.theoretical.l_stats_from_cdf] or
[`l_stats_from_ppf`][lmo.theoretical.l_stats_from_ppf], respectively.
For direct calculation of the L-stats from a CDF or PPF function, see

- [`lmo.theoretical.l_stats_from_cdf`][lmo.theoretical.l_stats_from_cdf]
- [`lmo.theoretical.l_stats_from_ppf`][lmo.theoretical.l_stats_from_ppf]
///

An overview of the L-location, L-scale, L-skewness and L-kurtosis,
of a bunch of popular univariate probability distributions, for which they
exist (in closed form).
An overview of the exact L-location, L-scale, L-skewness and L-kurtosis
of some well-known (univariate) probability distributions.

### L-stats

Expand Down Expand Up @@ -782,8 +787,8 @@ compactly expressed as
& \text{if } \alpha = 0 \wedge r = 1 \\
\displaystyle \frac{1}{\alpha r} \left[
\frac
{\B(t + 1 - \alpha,\ r - 1 + \alpha)}
{\B(r + s + t - 1 - \alpha,\ \alpha)}
{\B(r + \alpha - 1,\ t - \alpha + 1)}
{\B(\alpha,\ r + s + t - \alpha + 1)}
- \ffact{1}{r}
\right]
& \text{otherwise,}
Expand Down Expand Up @@ -824,7 +829,7 @@ There are several notable special cases of the GPD:

### Burr III / Dagum

The *Burr III* distribution [^BURR], also known as the
The *Burr III* distribution [@burr1942], also known as the
[*Dagum distribution*](https://wikipedia.org/wiki/Dagum_distribution), has two
shape parameters \( \alpha \) and \( \beta \), both restricted to the
positive reals
Expand Down Expand Up @@ -964,7 +969,7 @@ Its general \( r \)-th trimmed L-moment are:
\tlmoment{s,t}{r} =
\frac{1}{r}
\sum_{k = t + 1}^{r + s + t}
(-1)^{k - 1}
(-1)^{k - t - 1}
\binom{r + k - 2}{r + t - 1}
\binom{r + s + t}{k}
\frac{\B\bigl(1 / \alpha,\ 1 + k \beta \bigr)}{\alpha}
Expand Down
7 changes: 0 additions & 7 deletions docs/examples/lmm.ipynb
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Fitting the Generalized Extreme Value Distribution "
]
},
{
"cell_type": "code",
"execution_count": 1,
Expand Down
14 changes: 6 additions & 8 deletions docs/examples/visual_intro.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# A visual introduction to L-moments\n"
"## Required dependencies\n",
"\n",
"This notebook requires that you have \n",
"[`matplotlib`](https://pypi.org/project/matplotlib/) installed,\n",
"and, of course, [Lmo](https://pypi.org/project/lmo/) (preferrably the latest\n",
"stable release)."
]
},
{
Expand Down
8 changes: 6 additions & 2 deletions docs/styles/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ tr.row-double-top > td {
border-top: 0.15rem double var(--md-typeset-table-color) !important;
}

.md-grid {
max-width: 1440px;
}

/* Workarounds */
td,
/* td,
th {
white-space: nowrap;
}
} */
.md-typeset__scrollwrap > .md-typeset__table > table,
.md-typeset div.arithmatex {
overflow-y: hidden;
Expand Down
2 changes: 1 addition & 1 deletion lmo/_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def l_moment(
- $(0, 0)$ or $(0)$: The original **L**-moment, introduced by
Hosking in 1990.
- $(t, t)$ or $(t)$: **TL**-moment (**T**rimmed L-moment)
$\\lambda_r^t$, with symmetric trimming. First introduced by
$\lambda_r^{(t)}$, with symmetric trimming. First introduced by
Elamir & Seheult in 2003, and refined by Hosking in 2007.
Generally more robust than L-moments. Useful for fitting
pathological distributions, such as the Cauchy distribution.
Expand Down
Loading

0 comments on commit bcf87d2

Please sign in to comment.