Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Student's T distribution page #480

Merged
merged 4 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/examples/normal_distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ F(x \mid \mu, \sigma) =
\frac{1}{2} \left[ 1 + \text{erf} \left( \frac{x - \mu}{\sigma \sqrt{2}} \right) \right]
$$

where [erf](https://en.wikipedia.org/wiki/Error_function) is the error function.
where erf is the [error function](https://en.wikipedia.org/wiki/Error_function).


```{seealso}
Expand Down
Binary file modified docs/examples/students_t.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 102 additions & 0 deletions docs/examples/students_t_distribution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
jupytext:
text_representation:
extension: .md
format_name: myst
kernelspec:
display_name: Python 3
language: python
name: python3
---

# Student's t Distribution

The Student's t distribution, also known as the t-distribution, is a continuous probability distribution that resembles the normal distribution but with heavier tails. It is characterized by its bell-shaped curve, symmetric around the mean, and can defined by three parameters: the degrees of freedom ($\nu$), the location parameter ($\mu$), and the scale parameter ($\sigma$). The smaller the value of ($\nu$), the heavier the tails of the distribution.

It is often used in Bayesian analysis particulary as a robust alternative to the Normal due to the possibility of having heavier tails.


## Probability Density Function (PDF):

```{code-cell}
---
tags: [remove-input]
mystnb:
image:
alt: Student's t Distribution PDF
---

import matplotlib.pyplot as plt
import arviz as az
from preliz import StudentT
az.style.use('arviz-doc')
nus = [2., 5., 5.]
mus = [0., 0., -4.]
sigmas = [1., 1., 2.]
for nu, mu, sigma in zip(nus, mus, sigmas):
StudentT(nu, mu, sigma).plot_pdf(support=(-10,6))

```

## Cumulative Distribution Function (CDF):

```{code-cell}
---
tags: [remove-input]
mystnb:
image:
alt: Student's t Distribution CDF
---

for nu in nus:
StudentT(nu, mu, sigma).plot_cdf(support=(-10,6))
```

## Key properties and parameters:

```{eval-rst}
======== ==========================================
Support :math:`x \in \mathbb{R}`
Mean :math:`\mu` for :math:`\nu > 1`, otherwise undefined
Variance :math:`\frac{\nu}{\nu-2}` for :math:`\nu > 2`,
:math:`\infty` for :math:`1 < \nu \le 2`, otherwise undefined
======== ==========================================
```

**Probability Density Function (PDF):**

$$
f(x \mid \nu, \mu, \sigma) = \frac{\Gamma \left(\frac{\nu+1}{2} \right)} {\sqrt{\nu\pi}\Gamma \left(\frac{\nu}{2} \right)} \left(1+\frac{x^2}{\nu} \right)^{-\frac{\nu+1}{2}}
$$

where $\Gamma$ is the [gamma function](https://en.wikipedia.org/wiki/Gamma_function).

**Cumulative Distribution Function (CDF):**

$$
F(y \mid \nu, \mu, \sigma) =
\begin{cases}
1 - \frac{1}{2} I_{\frac{\nu}{x^2 + \nu}} \left( \frac{\nu}{2}, \frac{1}{2} \right) & \text{for } x = \frac{y - \mu}{\sigma} \leq 0, \\[0.5em]
\frac{1}{2} I_{\frac{\nu}{x^2 + \nu}} \left( \frac{\nu}{2}, \frac{1}{2} \right) & \text{for } x = \frac{y - \mu}{\sigma} > 0,
\end{cases}
$$

where $I_x(a, b)$ denotes the [regularized incomplete beta function](https://en.wikipedia.org/wiki/Regularized_incomplete_beta_function).



```{seealso}
:class: seealso

**Common Alternatives:**

- [Skewed Student's t Distribution](skew_studentt_distribution.md) - Extends the Student's t-distribution by introducing a skewness parameter, allowing for the modeling of data that is not symmetrically distributed.
- [Half-Student's t Distribution](halfstudentt_distribution.md) - Considers only the positive values of the Student's t-distribution.
- [Normal Distribution](normal_distribution.md) - When $\nu \to \infty$, the t-distribution converges to the normal distribution.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the skew student t

- [Cauchy Distribution](cauchy_distribution.md) - The Cauchy distribution is a special case of the Student's t-distribution with $\nu=1$.
```
## References

- Wikipedia. [Student's t-distribution](https://en.wikipedia.org/wiki/Student%27s_t-distribution)


43 changes: 0 additions & 43 deletions docs/examples/students_t_distribution.rst

This file was deleted.

2 changes: 1 addition & 1 deletion docs/gallery_content.rst
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ Continuous Distributions
Skew-Normal

.. grid-item-card::
:link: ./examples/student_t_distribution.html
:link: ./examples/students_t_distribution.html
:text-align: center
:shadow: none
:class-card: example-gallery
Expand Down
Loading