Handbook
Glossary
logseries-random* ( p rnd -- n )
Vocabulary
random
Inputs
p
an
object
rnd
an
object
Outputs
n
an
object
Definition
USING:
kernel
math
math.functions
;
IN:
random
::
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
;