Handbook
Glossary
weighted-randoms ( length histogram -- seq )
Vocabulary
math.extras
Inputs
length
an
object
histogram
an
object
Outputs
seq
an
object
Definition
USING:
assocs
kernel
math
math.statistics
namespaces
random
sequences
sorting.extras
;
IN:
math.extras
:
weighted-randoms
( length histogram -- seq )
unzip
cum-sum
swap
[
[
last
>float
random-generator
get
]
keep
]
dip
[
[
[
random*
]
2curry
]
dip
[
bisect-left
]
curry
compose
]
dip
[
nth
]
curry
compose
replicate
;