Skip to content

Commit

Permalink
Distributions Gallery: Add VonMises (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleicazatti authored Oct 31, 2024
1 parent 0e986dd commit e613494
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 1 deletion.
89 changes: 89 additions & 0 deletions docs/examples/gallery/vonmises.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
jupytext:
text_representation:
extension: .md
format_name: myst
kernelspec:
display_name: Python 3
language: python
name: python3
---
# Von Mises Distribution

<audio controls> <source src="../../_static/vonmises.mp3" type="audio/mpeg"> This browser cannot play the pronunciation audio file for this distribution. </audio>

The Von Mises distribution is a continuous probability distribution on the unit circle. It is characterized by two parameters: $\mu$ and $\kappa$, which are the mean direction and concentration parameter, respectively.

The Von Mises distribution is the circular analogue of the normal distribution, and it is used to model circular data, such as wind directions, compass bearings, or angles.

## Probability Density Function (PDF):

```{code-cell}
---
tags: [remove-input]
mystnb:
image:
alt: Von Mises Distribution PDF
---
import numpy as np
from preliz import style, VonMises
style.use('preliz-doc')
mus = [0., 0., 0., -2.5]
kappas = [.01, 0.5, 4., 2.]
for mu, kappa in zip(mus, kappas):
VonMises(mu, kappa).plot_pdf(support=(-np.pi,np.pi))
```

## Cumulative Distribution Function (CDF):

```{code-cell}
---
tags: [remove-input]
mystnb:
image:
alt: Von Mises Distribution CDF
---
for mu, kappa in zip(mus, kappas):
VonMises(mu, kappa).plot_cdf(support=(-np.pi,np.pi))
```

## Key properties and parameters:

```{eval-rst}
======== ==========================================
Support :math:`x \in (-\pi, \pi)`
Mean :math:`\mu`
Variance :math:`1 - I_1(\kappa) / I_0(\kappa)`
======== ==========================================
```

**Probability Density Function (PDF):**

$$
f(x|\mu, \kappa) = \frac{e^{\kappa \cos(x - \mu)}}{2\pi I_0(\kappa)}
$$

where $I_0(\kappa)$ is the [modified Bessel function of the first kind](https://en.wikipedia.org/wiki/Bessel_function#Modified_Bessel_functions:_I%CE%B1,_K%CE%B1).

**Cumulative Distribution Function (CDF):**

The Von Mises distribution does not have an analytical expression for the CDF. However, it can be evaluated numerically by integrating the PDF in the interval $(-\pi, x)$:

$$
F(x|\mu, \kappa) = \frac{1}{2\pi I_0(\kappa)} \int_{-\pi}^{x} e^{\kappa \cos(t - \mu)} dt
$$

```{seealso}
:class: seealso
**Related Distributions:**
- [Normal Distribution](normal.md) - When $\kappa \to \infty$, the Von Mises distribution approximates the normal distribution.
- [Uniform Distribution](uniform.md) - When $\kappa = 0$, the Von Mises distribution converges to the uniform distribution in the interval $(-\pi, \pi)$.
```

## References

- [Wikipedia - Von Mises distribution](https://en.wikipedia.org/wiki/Von_Mises_distribution)
2 changes: 1 addition & 1 deletion docs/gallery_content.rst
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ Continuous Distributions
Uniform

.. grid-item-card::
:link: ./api_reference.html#preliz.distributions.vonmises.VonMises
:link: ./examples/gallery/vonmises.html
:text-align: center
:shadow: none
:class-card: example-gallery
Expand Down

0 comments on commit e613494

Please sign in to comment.