Why does VonMises distribution generate variates outside of [-pi, pi]?

VonMises distribution has the support of [-pi, pi]. Why does the distribution generate the values outside of this region?

d = pm.VonMises.dist(mu=100, kappa=0.001)

This is working as expected.

You set the location parameter mu to 100, so the maximum value is mu + pi, or roughly 103.

No @sammosummo, that must not be the case. Support for VonMises is [-\pi, \pi] irrespective of the location (mu). This is a nice observation though as now we know that mu is getting added (or forgot to be subtracted) somewhere during sampling. Although this works perfectly fine when model is declared in a context.

Take a look at the scipy docs for the Von Mises Distribution, called by PyMC3.

It only has a kappa parameter, not mu. You can see that the generic loc and scale parameters work entirely consistently for this distribution as all other scipy distributions, but in this case, they also happen to change the support.

I think it’s a design feature that PyMC3 is consistent with scipy. However, I agree that in this case, it probably shouldn’t be calling loc as mu internally, and it may be better if PyMC3 conformed to the standard definition of Von Mises, perhaps in a separate class.


Oh! My bad. Thanks for the clarification!

In the current implementation it brakes posterior predictive samplings, because the observations are distributed within -pi, -pi and the posterior is shifted. Since mu can be a distribution itself, I’m not sure how to I can compare the posterior with the observations.