Circular Distributions

Circular distributions are defined for finite values y in any interval of length 2π.

Von Mises distribution

Probability density function

If μR and κR+, then for yR, VonMises(y|μ,κ)=exp(κcos(yμ))2πI0(κ). In order for this density to properly normalize, y must be restricted to some interval (c,c+2π) of length 2π, because cc+2πVonMises(y|μ,κ)dy=1. Similarly, if μ is a parameter, it will typically be restricted to the same range as y.

If κ>0, a von Mises distribution with its 2π interval of support centered around its location μ will have a single mode at μ; for example, restricting y to (π,π) and taking μ=0 leads to a single local optimum at the mode μ. If the location μ is not in the center of the support, the density is circularly translated and there will be a second local maximum at the boundary furthest from the mode. Ideally, the parameterization and support will be set up so that the bulk of the probability mass is in a continuous interval around the mean μ.

For κ=0, the Von Mises distribution corresponds to the circular uniform distribution with density 1/(2π) (independently of the values of y or μ).

Distribution statement

y ~ von_mises(mu, kappa)

Increment target log probability density with von_mises_lupdf(y | mu, kappa).

Available since 2.0

Stan functions

real von_mises_lpdf(reals y | reals mu, reals kappa)
The log of the von mises density of y given location mu and scale kappa.

Available since 2.18

real von_mises_lupdf(reals y | reals mu, reals kappa)
The log of the von mises density of y given location mu and scale kappa dropping constant additive terms.

Available since 2.25

real von_mises_cdf(reals y | reals mu, reals kappa)
The von mises cumulative distribution function of y given location mu and scale kappa.

Available since 2.29

real von_mises_lcdf(reals y | reals mu, reals kappa)
The log of the von mises cumulative distribution function of y given location mu and scale kappa.

Available since 2.29

real von_mises_lccdf(reals y | reals mu, reals kappa)
The log of the von mises complementary cumulative distribution function of y given location mu and scale kappa.

Available since 2.29

R von_mises_rng(reals mu, reals kappa)
Generate a Von Mises variate with location mu and scale kappa (i.e. returns values in the interval [(μmod2π)π,(μmod2π)+π]); may only be used in transformed data and generated quantities blocks. For a description of argument and return types, see section vectorized PRNG functions.

Available since 2.18

Numerical stability

Evaluating the Von Mises distribution for κ>100 is numerically unstable in the current implementation. Nathanael I. Lichti suggested the following workaround on the Stan users group, based on the fact that as κ, VonMises(y|μ,κ)Normal(μ,1/κ). The workaround is to replace y ~ von_mises(mu,kappa) with

if (kappa < 100) {
  y ~ von_mises(mu, kappa);
} else {
  y ~ normal(mu, sqrt(1 / kappa));
}
Back to top