Handbook
Glossary
geometric-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
::
geometric-random*
( p rnd -- n )
p 0.3333333333333333
>=
[
1.0 p
-
:>
q rnd
random-unit*
:>
U 1 p p
[
U
over
>
]
[
[
1
+
]
[
q
*
]
[
dupd
+
]
tri*
]
while
2drop
]
[
1.0 rnd
random-unit*
-
log
1.0 p
-
log
/
ceiling
>integer
]
if
;