von-mises-random* ( mu kappa rnd -- n )


Vocabulary
random

Inputs
muan object
kappaan object
rndan object


Outputs
nan object


Definition


:: von-mises-random* ( mu kappa rnd -- n )
kappa 0.000001 <=
[ 2pi rnd random-unit* * ] [
4.0 kappa sq * 1.0 + sqrt 1.0 + :> a a 2.0 a * sqrt -
2.0 kappa * / :> b b sq 1.0 + 2.0 b * /
:> r 0 :> c! 0 :> _f! [
rnd random-unit*
{ [ 2.0 c - c * < ] [ 1.0 c - e^ c * <= ] } 1|| not
] [
rnd random-unit* pi * cos :> z r z * 1.0 + r z + /
_f! r _f - kappa * c!
] do while mu 2pi mod _f cos rnd random-unit* 0.5 >
[ + ] [ - ] if
] if ;