diff --git a/docs/examples/gallery/log_logistic.md b/docs/examples/gallery/log_logistic.md new file mode 100644 index 00000000..c31f563d --- /dev/null +++ b/docs/examples/gallery/log_logistic.md @@ -0,0 +1,90 @@ +--- +jupytext: + text_representation: + extension: .md + format_name: myst +kernelspec: + display_name: Python 3 + language: python + name: python3 +--- +# Log-Logistic Distribution + + + +The log-logistic distribution, also known as the Fisk distribution, is a continuous probability distribution that is used to model non-negative random variables. It is characterized by two parameters: a scale parameter ($\alpha$), which is also the median of the distribution, and a shape parameter ($\beta$). The dispersion of the distribution decreases as $\beta$ increases. + +The log-logistic distribution is often used in survival analysis as a parametric model for events whose rate increases initially and decreases later, as, for example, mortality rate from cancer following diagnosis or treatment. It has been used in hydrology for modelling stream flow rates and precipitation. It is also used in reliability engineering to model the lifetime of components and systems. + + +## Probability Density Function (PDF): + +```{code-cell} +--- +tags: [remove-input] +mystnb: + image: + alt: Log-Logistic Distribution PDF +--- + +import matplotlib.pyplot as plt + +from preliz import LogLogistic, style +style.use('preliz-doc') +alphas = [1, 1, 1, 1, 2] +betas = [1, 2, 4, 8, 8] +for alpha, beta in zip(alphas, betas): + LogLogistic(alpha, beta).plot_pdf(support=(0, 6)) +``` + +## Cumulative Distribution Function (CDF): + +```{code-cell} +--- +tags: [remove-input] +mystnb: + image: + alt: Log-Logistic Distribution CDF +--- + +for alpha, beta in zip(alphas, betas): + LogLogistic(alpha, beta).plot_cdf(support=(0, 6)) +``` + +## Key properties and parameters: + +```{eval-rst} +======== ========================================================================== +Support :math:`x \in [0, \infty)` +Mean :math:`{\alpha\,\pi/\beta \over \sin(\pi/\beta)}` if :math:`\beta>1`, else undefined +Variance :math:`\alpha^2 \left(2b / \sin 2b -b^2 / \sin^2 b \right), \quad \beta>2` +======== ========================================================================== +``` + +**Probability Density Function (PDF):** + +$$ +f(x|\alpha, \beta) = \frac{ (\beta/\alpha)(x/\alpha)^{\beta-1}}{\left( 1+(x/\alpha)^{\beta} \right)^2} +$$ + +**Cumulative Distribution Function (CDF):** + +$$ +F(x|\alpha, \beta) = \frac{1}{1 + (x/\alpha)^{-\beta}} +$$ + +```{seealso} +:class: seealso + +**Common Alternatives:** + +- [Log-Normal Distribution](log_normal.md) - The log-logistic distribution is similar to the log-normal distribution, but with heavier tails. + +**Related Distributions:** + +- [Logistic Distribution](logistic.md) - If a random variable $X$ is distributed as a log-logistic distribution, then its logarithm $\log(X)$ follows a logistic distribution. +``` + +## References + +- [Wikipedia - Log-logistic distribution](https://en.wikipedia.org/wiki/Log-logistic_distribution) \ No newline at end of file diff --git a/docs/gallery_content.rst b/docs/gallery_content.rst index cea56a9c..dc3dfa05 100644 --- a/docs/gallery_content.rst +++ b/docs/gallery_content.rst @@ -211,7 +211,7 @@ Continuous Distributions Logistic .. grid-item-card:: - :link: ./api_reference.html#preliz.distributions.loglogistic.LogLogistic + :link: ./examples/gallery/log_logistic.html :text-align: center :shadow: none :class-card: example-gallery diff --git a/preliz/distributions/loglogistic.py b/preliz/distributions/loglogistic.py index 4a808657..1a0c9ea0 100644 --- a/preliz/distributions/loglogistic.py +++ b/preliz/distributions/loglogistic.py @@ -30,10 +30,10 @@ class LogLogistic(Continuous): from preliz import LogLogistic, style style.use('preliz-doc') - mus = [1, 1, 2] - sigmas = [4, 8, 8] - for mu, sigma in zip(mus, sigmas): - LogLogistic(mu, sigma).plot_pdf(support=(0, 6)) + alphas = [1, 1, 2] + betas = [4, 8, 8] + for alpha, beta in zip(alphas, betas): + LogLogistic(alpha,beta).plot_pdf(support=(0, 6)) ======== ========================================================================== Support :math:`x \in [0, \infty)`