From ad86e2f0240c34bfc3760ee0a56f40ac1500b901 Mon Sep 17 00:00:00 2001 From: aleicazatti Date: Wed, 10 Jul 2024 22:12:56 -0300 Subject: [PATCH 01/11] Add uniform distribution page --- docs/examples/uniform_distribution.md | 103 ++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 docs/examples/uniform_distribution.md diff --git a/docs/examples/uniform_distribution.md b/docs/examples/uniform_distribution.md new file mode 100644 index 00000000..bf68902b --- /dev/null +++ b/docs/examples/uniform_distribution.md @@ -0,0 +1,103 @@ +--- +jupytext: + text_representation: + extension: .md + format_name: myst +kernelspec: + display_name: Python 3 + language: python + name: python3 +--- +# Uniform Distribution + +The Uniform distribution is a continuous probability distribution bounded between two real numbers, $lower$ and $upper$, representing the lower and upper bounds, respectively. In other notations, these parameters are often denoted as $a$ and $b$, or $\alpha$ and $\beta$, respectively. + +The probability density of the Uniform distribution is constant between $lower$ and $upper$ and zero elsewhere. Despite its simplicity, it is rare to observe a real-world distribution where all outcomes are equally likely. + +The Uniform distribution is the maximum entropy probability distribution for a random variable under no constraint other than that it is contained in the interval $[lower,upper]$. It's often employed in random sampling, for generating random numbers, and as a non-informative (flat) prior in Bayesian statistics when there is no prior knowledge about the parameter other than its range. + +## Probability Density Function (PDF): + +```{code-cell} +--- +tags: [remove-input] +mystnb: + image: + alt: Uniform Distribution PDF +--- + +import matplotlib.pyplot as plt +import arviz as az +from preliz import Uniform +az.style.use('arviz-doc') +ls = [1, -2] +us = [6, 2] +for l, u in zip(ls, us): + ax = Uniform(l, u).plot_pdf() +ax.set_ylim(0, 0.3) + +``` + +## Cumulative Distribution Function (CDF): + +```{code-cell} +--- +tags: [remove-input] +mystnb: + image: + alt: Uniform Distribution CDF +--- + +for l, u in zip(ls, us): + Uniform(l, u).plot_cdf() +``` + +## Key properties and parameters: + +```{eval-rst} +======== ===================================== +Support :math:`x \in [lower, upper]` +Mean :math:`\dfrac{lower + upper}{2}` +Variance :math:`\dfrac{(upper - lower)^2}{12}` +======== ===================================== +``` + +**Probability Density Function (PDF):** + +$$ +f(x \mid lower, upper) = + \begin{cases} + \dfrac{1}{upper - lower} & \text{for } x \in [lower, upper] \\ + 0 & \text{otherwise} + \end{cases} +$$ + +**Cumulative Distribution Function (CDF):** + +$$ +F(x \mid lower, upper) = + \begin{cases} + 0 & \text{for } x < lower \\ + \dfrac{x - lower}{upper - lower} & \text{for } x \in [lower, upper] \\ + 1 & \text{for } x > upper + \end{cases} +$$ + +```{seealso} +:class: seealso + +**Common Alternatives:** + +- [Beta Distribution](beta_distribution.md) - The Uniform distribution is a special case of the Beta distribution with $\alpha = \beta = 1$. + +**Related Distributions:** + +- [Triangular Distribution](triangular_distribution.md) - It is defined between a range of values, similar to the Uniform distribution, but with a peak at one of the points. +``` + +# References + +- Wikipedia - [Uniform distribution](https://en.wikipedia.org/wiki/Continuous_uniform_distribution) + + + From 90ddfaebd67aa047186249eb4c27a774eabec07a Mon Sep 17 00:00:00 2001 From: Osvaldo A Martin Date: Thu, 11 Jul 2024 09:41:30 -0300 Subject: [PATCH 02/11] Update docs/examples/uniform_distribution.md --- docs/examples/uniform_distribution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/uniform_distribution.md b/docs/examples/uniform_distribution.md index bf68902b..0e132d61 100644 --- a/docs/examples/uniform_distribution.md +++ b/docs/examples/uniform_distribution.md @@ -10,7 +10,7 @@ kernelspec: --- # Uniform Distribution -The Uniform distribution is a continuous probability distribution bounded between two real numbers, $lower$ and $upper$, representing the lower and upper bounds, respectively. In other notations, these parameters are often denoted as $a$ and $b$, or $\alpha$ and $\beta$, respectively. +The Uniform distribution is a continuous probability distribution bounded between two real numbers, $lower$ and $upper$, representing the lower and upper bounds, respectively. The probability density of the Uniform distribution is constant between $lower$ and $upper$ and zero elsewhere. Despite its simplicity, it is rare to observe a real-world distribution where all outcomes are equally likely. From a019d5fd60bb9d61c673ff5ba205f5a44d9e01c8 Mon Sep 17 00:00:00 2001 From: Osvaldo A Martin Date: Thu, 11 Jul 2024 09:41:49 -0300 Subject: [PATCH 03/11] Update docs/examples/uniform_distribution.md --- docs/examples/uniform_distribution.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/examples/uniform_distribution.md b/docs/examples/uniform_distribution.md index 0e132d61..192d8612 100644 --- a/docs/examples/uniform_distribution.md +++ b/docs/examples/uniform_distribution.md @@ -12,7 +12,10 @@ kernelspec: The Uniform distribution is a continuous probability distribution bounded between two real numbers, $lower$ and $upper$, representing the lower and upper bounds, respectively. -The probability density of the Uniform distribution is constant between $lower$ and $upper$ and zero elsewhere. Despite its simplicity, it is rare to observe a real-world distribution where all outcomes are equally likely. +The probability density of the Uniform distribution is constant between $lower$ and $upper$ and zero elsewhere. Some experiments of physical origin exhibit this kind of behaviour. For instance, if we record, for a long time, the times at which radioactive particles are emitted within each hour, the outcomes will be uniform on the interval [0, 60] minutes interval. + + +we encounter a continuous random variable that describes an experiment where the outcome is completely arbitrary, except that we know it lies between certain bounds. Many experiments of physical origin exhibit this kind of behavior. For instance, consider an experiment where we measure the emission of radioactive particles from some material over a long period. If we record the times at which particles are emitted within each hour, the outcomes will lie in the interval [0, 60] minutes The Uniform distribution is the maximum entropy probability distribution for a random variable under no constraint other than that it is contained in the interval $[lower,upper]$. It's often employed in random sampling, for generating random numbers, and as a non-informative (flat) prior in Bayesian statistics when there is no prior knowledge about the parameter other than its range. From 11ba684c91bc344d58250b8878af3ec193632d31 Mon Sep 17 00:00:00 2001 From: Osvaldo A Martin Date: Thu, 11 Jul 2024 09:41:56 -0300 Subject: [PATCH 04/11] Update docs/examples/uniform_distribution.md --- docs/examples/uniform_distribution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/uniform_distribution.md b/docs/examples/uniform_distribution.md index 192d8612..ba855a74 100644 --- a/docs/examples/uniform_distribution.md +++ b/docs/examples/uniform_distribution.md @@ -17,7 +17,7 @@ The probability density of the Uniform distribution is constant between $lower$ we encounter a continuous random variable that describes an experiment where the outcome is completely arbitrary, except that we know it lies between certain bounds. Many experiments of physical origin exhibit this kind of behavior. For instance, consider an experiment where we measure the emission of radioactive particles from some material over a long period. If we record the times at which particles are emitted within each hour, the outcomes will lie in the interval [0, 60] minutes -The Uniform distribution is the maximum entropy probability distribution for a random variable under no constraint other than that it is contained in the interval $[lower,upper]$. It's often employed in random sampling, for generating random numbers, and as a non-informative (flat) prior in Bayesian statistics when there is no prior knowledge about the parameter other than its range. +The Uniform distribution is the maximum entropy probability distribution for a random variable under no constraint other than that it is contained in the interval $[lower,upper]$. It's often employed for generating random numbers from the cumulative distribution function (see [inverse transform sampling](https://en.wikipedia.org/wiki/Inverse_transform_sampling)). It is also used as the basis of some statistical tests (see [probability integral transform](https://en.wikipedia.org/wiki/Probability_integral_transform)). Sometimes, it can be used as a "non-informative" (flat) prior in Bayesian statistics when there is no prior knowledge about the parameter other than its range, but this is discouraged unless the range has a physical meaning and values outside of it are impossible. ## Probability Density Function (PDF): From fa5ac2c25f462a3291faea167af26c7a68549df3 Mon Sep 17 00:00:00 2001 From: Osvaldo A Martin Date: Thu, 11 Jul 2024 09:42:02 -0300 Subject: [PATCH 05/11] Update docs/examples/uniform_distribution.md --- docs/examples/uniform_distribution.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/examples/uniform_distribution.md b/docs/examples/uniform_distribution.md index ba855a74..88ebb640 100644 --- a/docs/examples/uniform_distribution.md +++ b/docs/examples/uniform_distribution.md @@ -91,7 +91,8 @@ $$ **Common Alternatives:** -- [Beta Distribution](beta_distribution.md) - The Uniform distribution is a special case of the Beta distribution with $\alpha = \beta = 1$. +- [Beta Distribution](beta_distribution.md) - The Uniform distribution with $lower=0$, $upper=1$ is a special case of the Beta distribution with $\alpha = \beta = 1$. +- [Beta Scaled Distribution](beta_scaled distribution.md) - The Uniform distribution is a special case of the Beta scaled distribution with $\alpha = \beta = 1$ and $lower$, $upper$ parameters. **Related Distributions:** From 3016bfb18b14ffa218c756995952192d5d781b05 Mon Sep 17 00:00:00 2001 From: Osvaldo A Martin Date: Thu, 11 Jul 2024 09:42:08 -0300 Subject: [PATCH 06/11] Update docs/examples/uniform_distribution.md --- docs/examples/uniform_distribution.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/examples/uniform_distribution.md b/docs/examples/uniform_distribution.md index 88ebb640..8421e306 100644 --- a/docs/examples/uniform_distribution.md +++ b/docs/examples/uniform_distribution.md @@ -89,7 +89,6 @@ $$ ```{seealso} :class: seealso -**Common Alternatives:** - [Beta Distribution](beta_distribution.md) - The Uniform distribution with $lower=0$, $upper=1$ is a special case of the Beta distribution with $\alpha = \beta = 1$. - [Beta Scaled Distribution](beta_scaled distribution.md) - The Uniform distribution is a special case of the Beta scaled distribution with $\alpha = \beta = 1$ and $lower$, $upper$ parameters. From c726756d2f3229d8be72a19bdb0460a671b5831a Mon Sep 17 00:00:00 2001 From: Osvaldo A Martin Date: Thu, 11 Jul 2024 09:42:14 -0300 Subject: [PATCH 07/11] Update docs/examples/uniform_distribution.md --- docs/examples/uniform_distribution.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/examples/uniform_distribution.md b/docs/examples/uniform_distribution.md index 8421e306..f2dcd8b6 100644 --- a/docs/examples/uniform_distribution.md +++ b/docs/examples/uniform_distribution.md @@ -95,8 +95,9 @@ $$ **Related Distributions:** -- [Triangular Distribution](triangular_distribution.md) - It is defined between a range of values, similar to the Uniform distribution, but with a peak at one of the points. -``` +- [Beta Distribution](beta_distribution.md) - The Uniform distribution with $lower=0$, $upper=1$ is a special case of the Beta distribution with $\alpha = \beta = 1$. +- [Beta Scaled Distribution](beta_scaled distribution.md) - The Uniform distribution is a special case of the Beta Scaled distribution with $\alpha = \beta = 1$ and $lower$, $upper$ parameters. +- [Discrete Uniform Distribution](discrete_uniform_distribution.md) - The discrete version of the Uniform distribution. # References From 7fea130e2c5254572a01ebb9b5166cafc2d51f4d Mon Sep 17 00:00:00 2001 From: Osvaldo A Martin Date: Thu, 11 Jul 2024 10:29:01 -0300 Subject: [PATCH 08/11] Apply suggestions from code review --- docs/examples/uniform_distribution.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/examples/uniform_distribution.md b/docs/examples/uniform_distribution.md index f2dcd8b6..8ae842f6 100644 --- a/docs/examples/uniform_distribution.md +++ b/docs/examples/uniform_distribution.md @@ -37,7 +37,7 @@ ls = [1, -2] us = [6, 2] for l, u in zip(ls, us): ax = Uniform(l, u).plot_pdf() -ax.set_ylim(0, 0.3) +ax.set_ylim(0, 0.3); ``` @@ -90,8 +90,6 @@ $$ :class: seealso -- [Beta Distribution](beta_distribution.md) - The Uniform distribution with $lower=0$, $upper=1$ is a special case of the Beta distribution with $\alpha = \beta = 1$. -- [Beta Scaled Distribution](beta_scaled distribution.md) - The Uniform distribution is a special case of the Beta scaled distribution with $\alpha = \beta = 1$ and $lower$, $upper$ parameters. **Related Distributions:** From cdd1db56b269b3f99a8cc6b862ed7d17b54dd70e Mon Sep 17 00:00:00 2001 From: Osvaldo A Martin Date: Thu, 11 Jul 2024 10:49:48 -0300 Subject: [PATCH 09/11] Update docs/examples/uniform_distribution.md --- docs/examples/uniform_distribution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/uniform_distribution.md b/docs/examples/uniform_distribution.md index 8ae842f6..8ece860d 100644 --- a/docs/examples/uniform_distribution.md +++ b/docs/examples/uniform_distribution.md @@ -94,7 +94,7 @@ $$ **Related Distributions:** - [Beta Distribution](beta_distribution.md) - The Uniform distribution with $lower=0$, $upper=1$ is a special case of the Beta distribution with $\alpha = \beta = 1$. -- [Beta Scaled Distribution](beta_scaled distribution.md) - The Uniform distribution is a special case of the Beta Scaled distribution with $\alpha = \beta = 1$ and $lower$, $upper$ parameters. +- [Beta Scaled Distribution](beta_scaled_distribution.md) - The Uniform distribution is a special case of the Beta Scaled distribution with $\alpha = \beta = 1$ and $lower$, $upper$ parameters. - [Discrete Uniform Distribution](discrete_uniform_distribution.md) - The discrete version of the Uniform distribution. # References From 18dfe81d5d5c991d1e5deab631ef82b303be114b Mon Sep 17 00:00:00 2001 From: Osvaldo A Martin Date: Thu, 11 Jul 2024 10:51:22 -0300 Subject: [PATCH 10/11] Update docs/examples/uniform_distribution.md --- docs/examples/uniform_distribution.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/examples/uniform_distribution.md b/docs/examples/uniform_distribution.md index 8ece860d..ec6d4718 100644 --- a/docs/examples/uniform_distribution.md +++ b/docs/examples/uniform_distribution.md @@ -96,7 +96,6 @@ $$ - [Beta Distribution](beta_distribution.md) - The Uniform distribution with $lower=0$, $upper=1$ is a special case of the Beta distribution with $\alpha = \beta = 1$. - [Beta Scaled Distribution](beta_scaled_distribution.md) - The Uniform distribution is a special case of the Beta Scaled distribution with $\alpha = \beta = 1$ and $lower$, $upper$ parameters. - [Discrete Uniform Distribution](discrete_uniform_distribution.md) - The discrete version of the Uniform distribution. - # References - Wikipedia - [Uniform distribution](https://en.wikipedia.org/wiki/Continuous_uniform_distribution) From ca87038096bad00f0bb9bf00e63c9aae53f0cd18 Mon Sep 17 00:00:00 2001 From: Osvaldo A Martin Date: Thu, 11 Jul 2024 10:54:31 -0300 Subject: [PATCH 11/11] Update docs/examples/uniform_distribution.md --- docs/examples/uniform_distribution.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/examples/uniform_distribution.md b/docs/examples/uniform_distribution.md index ec6d4718..ae1c0b6d 100644 --- a/docs/examples/uniform_distribution.md +++ b/docs/examples/uniform_distribution.md @@ -96,6 +96,7 @@ $$ - [Beta Distribution](beta_distribution.md) - The Uniform distribution with $lower=0$, $upper=1$ is a special case of the Beta distribution with $\alpha = \beta = 1$. - [Beta Scaled Distribution](beta_scaled_distribution.md) - The Uniform distribution is a special case of the Beta Scaled distribution with $\alpha = \beta = 1$ and $lower$, $upper$ parameters. - [Discrete Uniform Distribution](discrete_uniform_distribution.md) - The discrete version of the Uniform distribution. +``` # References - Wikipedia - [Uniform distribution](https://en.wikipedia.org/wiki/Continuous_uniform_distribution)