von-mises-random-float ( mu kappa -- n )


Vocabulary
random

Inputs
muan object
kappaan object


Outputs
nan object


Definition


:: von-mises-random-float ( mu kappa -- n )
random-generator get :> rnd kappa 1.0e-06 <=
[ 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 ;