From c29a302f9e57f2052766e4ef7ba1cad8c339716f Mon Sep 17 00:00:00 2001 From: aleicazatti Date: Mon, 24 Jun 2024 23:17:47 -0300 Subject: [PATCH 1/3] add logistic distribution page --- docs/examples/logistic_distribution.md | 93 ++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 docs/examples/logistic_distribution.md diff --git a/docs/examples/logistic_distribution.md b/docs/examples/logistic_distribution.md new file mode 100644 index 00000000..13a89d0b --- /dev/null +++ b/docs/examples/logistic_distribution.md @@ -0,0 +1,93 @@ +--- +jupytext: + text_representation: + extension: .md + format_name: myst +kernelspec: + display_name: Python 3 + language: python + name: python3 +--- +# Logistic Distribution + +The logistic distribution is a continuous probability distribution with a shape that resembles the normal distribution, but with heavier tails. It is defined by two parameters: the mean ($\mu$) and the scale parameter ($s$). The mean determines the center of the distribution, while the scale parameter controls the steepness of the curve. + +Its cumulative distribution function is the [logistic function](https://en.wikipedia.org/wiki/Logistic_function), which is characterized by an S-shaped curve (sigmoid curve). It is particularly useful in modeling growth processes, such as population growth, where the rate of growth decreases as the population reaches its carrying capacity. + +In logistic regression (whether frequentist or Bayesian flavor), the logistic distribution is used to model the probability of a binary outcome based on one or more predictor variables. The logistic function maps any real value into the range [0, 1], making it suitable for binary classification tasks. + +## Probability Density Function (PDF): + +```{code-cell} +--- +tags: [remove-input] +mystnb: + image: + alt: Logistic Distribution PDF +--- + +import matplotlib.pyplot as plt +import arviz as az +from preliz import Logistic +az.style.use('arviz-doc') +mus = [0., 0., -2.] +ss = [1., 2., .4] +for mu, s in zip(mus, ss): + Logistic(mu, s).plot_pdf(support=(-5,5)) +``` + +## Cumulative Distribution Function (CDF): + +```{code-cell} +--- +tags: [remove-input] +mystnb: + image: + alt: Logistic Distribution CDF +--- + +for mu, s in zip(mus, ss): + Logistic(mu, s).plot_cdf(support=(-5,5)) +``` + + +## Key properties and parameters: + +```{eval-rst} +======== ========================================== +Support :math:`x \in \mathbb{R}` +Mean :math:`\mu` +Variance :math:`\frac{\pi^2}{3}s^2` +======== ========================================== +``` + +**Probability Density Function (PDF):** + + +$$ +f(x \mid \mu, s) = +\frac{e^{-(x-\mu)/s}}{s(1+e^{-(x-\mu)/s})^2} +$$ + +**Cumulative Distribution Function (CDF):** + +$$ +F(x \mid \mu, s) = \frac{1}{1 + e^{-(x - \mu) / s}} +$$ + +```{seealso} +:class: seealso + +**Common Alternatives:** + +- [Normal Distribution](normal_distribution.md) - Often used as an alternative to the logistic distribution when the tails are not of primary concern. +- [Cauchy Distribution](cauchy_distribution.md) - Has much heavier tails than the logistic distribution, making it a robust alternative when outliers are a concern. + +**Related Distributions:** + +- [Log-logistic Distribution](log_logistic_distribution.md) - The probability distribution of a random variable whose logarithm has a logistic distribution. +``` + +## References + +- [Wikipedia - Logistic Distribution](https://en.wikipedia.org/wiki/Logistic_distribution) \ No newline at end of file From c02f35c6c571110f7bf65188e76a9124cfb82243 Mon Sep 17 00:00:00 2001 From: aleicazatti Date: Tue, 25 Jun 2024 16:21:11 -0300 Subject: [PATCH 2/3] apply suggestion --- docs/examples/logistic_distribution.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/examples/logistic_distribution.md b/docs/examples/logistic_distribution.md index 13a89d0b..b26b77c2 100644 --- a/docs/examples/logistic_distribution.md +++ b/docs/examples/logistic_distribution.md @@ -82,6 +82,7 @@ $$ - [Normal Distribution](normal_distribution.md) - Often used as an alternative to the logistic distribution when the tails are not of primary concern. - [Cauchy Distribution](cauchy_distribution.md) - Has much heavier tails than the logistic distribution, making it a robust alternative when outliers are a concern. +- [Student's t Distribution](students_t_distribution.md) - A generalization of the normal distribution with heavier tails. **Related Distributions:** From ba502e8005a9081786b8b280fef125d7307dc064 Mon Sep 17 00:00:00 2001 From: Alejandro Icazatti Date: Tue, 25 Jun 2024 16:22:25 -0300 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Osvaldo A Martin --- docs/examples/logistic_distribution.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/examples/logistic_distribution.md b/docs/examples/logistic_distribution.md index b26b77c2..9604cff2 100644 --- a/docs/examples/logistic_distribution.md +++ b/docs/examples/logistic_distribution.md @@ -10,11 +10,11 @@ kernelspec: --- # Logistic Distribution -The logistic distribution is a continuous probability distribution with a shape that resembles the normal distribution, but with heavier tails. It is defined by two parameters: the mean ($\mu$) and the scale parameter ($s$). The mean determines the center of the distribution, while the scale parameter controls the steepness of the curve. +The logistic distribution is a continuous probability distribution with a shape that resembles the normal distribution but with heavier tails. Thus, it is sometimes used as a replacement for the normal when heavier tails are needed. It is defined by two parameters: the mean ($\mu$) and the scale parameter ($s$). The mean determines the center of the distribution, while the scale parameter controls the width. Its cumulative distribution function is the [logistic function](https://en.wikipedia.org/wiki/Logistic_function), which is characterized by an S-shaped curve (sigmoid curve). It is particularly useful in modeling growth processes, such as population growth, where the rate of growth decreases as the population reaches its carrying capacity. -In logistic regression (whether frequentist or Bayesian flavor), the logistic distribution is used to model the probability of a binary outcome based on one or more predictor variables. The logistic function maps any real value into the range [0, 1], making it suitable for binary classification tasks. +A logistic regression model is typically characterized by a Bernoulli distribution for the likelihood and the logistic function as the inverse link function. However, logistic regression can also be [described](https://en.wikipedia.org/wiki/Logistic_distribution#Logistic_regression) as a latent variable model where the error term follows a logistic distribution. ## Probability Density Function (PDF): @@ -86,7 +86,7 @@ $$ **Related Distributions:** -- [Log-logistic Distribution](log_logistic_distribution.md) - The probability distribution of a random variable whose logarithm has a logistic distribution. +- [Log-logistic Distribution](log_logistic_distribution.md) - If a random variable is distributed as a logistic, then its exponential is distributed as a log-logistic distribution. ``` ## References