Handbook
Glossary
<vose> ( dist -- vose )
Vocabulary
math
.
extras
Inputs
dist
an
object
Outputs
vose
an
object
Definition
USING:
arrays
assocs
kernel
math
math.vectors
sequences
;
IN:
math.extras
::
<vose>
( dist -- vose )
V{
}
clone
:>
small
V{
}
clone
:>
large dist
assoc-size
:>
n n
f
<array>
:>
alias dist
unzip
dup
[
length
]
[
sum
]
bi
/f
v*n
:>
( items probs ) probs
[
swap
1.0
<
small large
?
push
]
each-index
[
small
empty?
large
empty?
or
]
[
small
pop
:>
s large
pop
:>
l l s alias
set-nth
l
dup
probs
[
s probs
nth
+
1
-
dup
]
change-nth
1.0
<
small large
?
push
]
until
1.0 large
[
probs
set-nth
]
with
each
1.0 small
[
probs
set-nth
]
with
each
n items probs alias
vose
boa
;