logseries-random* ( p rnd -- n )


Vocabulary
random

Inputs
pan object
rndan object


Outputs
nan object


Definition


:: logseries-random* ( p rnd -- n )
1.0 p - log :> r f [
drop rnd random-unit* :> V V p >=
[ 1 ] [
rnd random-unit* :> U 1.0 r U * e^ - :> q V 0 >
V q sq <= and
[ 1 V log q log / + floor >integer [ f ] when-zero ]
[ f ] if [ V q >= 1 2 ? ] unless*
] if dup not
] loop ;