Bug introduced in 10.2 or earlier and fixed in 10.3


FullSimplify[PDF[VonMisesDistribution[μ, 0], x], -π + μ <= x <= π + μ] == 
 FullSimplify[PDF[UniformDistribution[{μ - π, μ + π}], x], -π + μ <= x <= π + μ]

(* True *)

RandomVariate@UniformDistribution[{0 - π, 0 + π}]
RandomVariate@VonMisesDistribution[0, 0]


CompiledFunction::cfn: Numerical error encountered at instruction 19; proceeding with uncompiled evaluation. >>

Power::infy: Infinite expression 1/0 encountered. >>

Infinity::indet: Indeterminate expression 0 ComplexInfinity encountered. >>

at which point it just hangs, never completing.

This appears to be for any mean with concentration 0.

  • $\begingroup$ Your first line can be written more simply as Simplify[PDF[VonMisesDistribution[\[Mu], 0], x] == PDF[UniformDistribution[{\[Mu] - \[Pi], \[Mu] + \[Pi]}], x], -\[Pi] + \[Mu] <= x <= \[Pi] + \[Mu]] $\endgroup$
    – Bob Hanlon
    Aug 6, 2015 at 6:33
  • 2
    $\begingroup$ If memory serves, the method used internally is the rejection method of Best and Fisher; if you'll look through their algorithm, they implicitly make the assumption that $\kappa$ is positive. So, their algorithm will not work in your case, and there should have been a separate internal handler for $\kappa=0$. $\endgroup$ Aug 6, 2015 at 13:35
  • 2
    $\begingroup$ This is indeed a bug. We're looking into it. $\endgroup$
    – Stefan R
    Aug 6, 2015 at 19:42

2 Answers 2


To me this looks like a bug. A possible workaround is to use ProbabilityDistribution together with the PDF of the VonMisesDistribution:

RandomVariate@ProbabilityDistribution[PDF[VonMisesDistribution[0, 0], x], {x, -∞, ∞}]

$\ $ 1.99422

This bug is caused by the evaluation of

Statistics`NormalDistributionsDump`compiledvonmisesrandom[0, 0, 1]
  • $\begingroup$ As noted in WRI comment, it is indeed a bug. $\endgroup$
    – ciao
    Aug 6, 2015 at 20:16
  • $\begingroup$ Oops - forgot to upvote you, +1 $\endgroup$
    – ciao
    Aug 6, 2015 at 20:41

As noted in the comment by WRI staff, this is indeed a bug in the interplay between RandomVariate and the distribution at hand.

The obvious workaround for now is to use

UniformDistribution[{μ - Pi, μ + Pi}] 

for zero-concentration cases.

  • $\begingroup$ If I got it correct RandomVariate@VonMisesDistribution[0, 0] will call Statistics`NormalDistributionsDump`compiledvonmisesrandom[0, 0, 1] and if you have a look into that, you'll find things like (2*kappa)^(-1). $\endgroup$
    – Karsten7
    Aug 6, 2015 at 21:45
  • $\begingroup$ @Karsten7.: yep - I titled it with the dist and not RandomVariate since it seems to me it's the specific "hooks" for the dist that have boo-boos... I just used Block in the piece of code affected for me and gave a downvalue for VMD with zero concentration that evaluates to the uniform. $\endgroup$
    – ciao
    Aug 6, 2015 at 22:08
  • $\begingroup$ @Karsten, then yes, they are indeed using Best-Fisher. As noted, it can't handle $\kappa=0$. $\endgroup$ Aug 7, 2015 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.