-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Distribution Gallery: Add Gamma (#506)
* Distribution Gallery: Add Gamma * Apply suggestions from code review Co-authored-by: Osvaldo A Martin <[email protected]> --------- Co-authored-by: Osvaldo A Martin <[email protected]>
- Loading branch information
1 parent
63df0ef
commit ce64174
Showing
3 changed files
with
100 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
--- | ||
jupytext: | ||
text_representation: | ||
extension: .md | ||
format_name: myst | ||
kernelspec: | ||
display_name: Python 3 | ||
language: python | ||
name: python3 | ||
--- | ||
# Gamma Distribution | ||
|
||
The gamma distribution is a continuous probability distribution that describes the time until a specified number of events occur in a Poisson process, in which $\alpha$ events occur continuously and independently at a constant average rate $\beta$. The gamma distribution is characterized by two parameters: the shape parameter $\alpha$ and the rate parameter $\beta$. | ||
|
||
The gamma distribution is widely used in many settings, including modeling the time until a specified number of decays of a radioactive atom, the time until a specified number of seizures in patients with epilepsy, the time until a specified number of failures of a machine, and the time until a specified number of changes in the price of a stock. | ||
|
||
The gamma distribution is used as a conjugate prior for the exponential distribution and for the precision of the normal distribution. It can also used as prior for scale parameters, in particular when there is interest in avoiding values close to zero or one wants to include more information than with other prior commonly used for scale parameter like the halfnormal or the exponential. | ||
|
||
## Probability Density Function (PDF): | ||
|
||
```{code-cell} | ||
--- | ||
tags: [remove-input] | ||
mystnb: | ||
image: | ||
alt: Gamma Distribution PDF | ||
--- | ||
import arviz as az | ||
from preliz import Gamma | ||
az.style.use('arviz-doc') | ||
alphas = [1, 3, 7.5] | ||
betas = [0.5, 1., 1.] | ||
for alpha, beta in zip(alphas, betas): | ||
Gamma(alpha, beta).plot_pdf() | ||
``` | ||
|
||
## Cumulative Distribution Function (CDF): | ||
|
||
```{code-cell} | ||
--- | ||
tags: [remove-input] | ||
mystnb: | ||
image: | ||
alt: Gamma Distribution CDF | ||
--- | ||
for alpha, beta in zip(alphas, betas): | ||
Gamma(alpha, beta).plot_cdf() | ||
``` | ||
|
||
## Key properties and parameters: | ||
|
||
```{eval-rst} | ||
======== ========================================== | ||
Support :math:`x \in (0, \infty)` | ||
Mean :math:`\frac{\alpha}{\beta}` | ||
Variance :math:`\frac{\alpha}{\beta^2}` | ||
======== ========================================== | ||
``` | ||
|
||
**Probability Density Function (PDF):** | ||
|
||
$$ | ||
f(x|\alpha, \beta) = \frac{\beta^\alpha x^{\alpha - 1} e^{-\beta x}}{\Gamma(\alpha)} | ||
$$ | ||
|
||
where $\Gamma$ is the [gamma function](https://en.wikipedia.org/wiki/Gamma_function). | ||
|
||
**Cumulative Distribution Function (CDF):** | ||
|
||
$$ | ||
F(x|\alpha, \beta) = \frac{1}{\Gamma(\alpha)} \gamma(\alpha, \beta x) | ||
$$ | ||
|
||
where $\gamma$ is the [lower incomplete gamma function](https://en.wikipedia.org/wiki/Incomplete_gamma_function). | ||
|
||
```{seealso} | ||
:class: seealso | ||
**Common Alternatives:** | ||
- [Exponential Distribution](exponential.md) - A special case of the Gamma distribution with the shape parameter $\alpha = 1$. | ||
- [Chi-Squared Distribution](chisquared.md) - A special case of the Gamma distribution with the shape parameter $\alpha = \nu/2$ and the scale parameter $\beta = 1/2$. | ||
**Related Distributions:** | ||
- [Inverse Gamma Distribution](inverse-gamma.md) - The reciprocal of a gamma-distributed random variable. | ||
- [Poisson Distribution](poisson.md) - While the Gamma distribution models the time until a specified number of events occur in a Poisson process, the Poisson distribution models the number of events in fixed intervals of time or space. | ||
- [Negative Binomial Distribution](negative-binomial.md) - The discrete counterpart of the Gamma distribution, modeling the number of trials needed to achieve a specified number of successes in a sequence of Bernoulli trials. | ||
``` | ||
|
||
|
||
## References | ||
|
||
- [Wikipedia - Gamma distribution](https://en.wikipedia.org/wiki/Gamma_distribution) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters