lagged-fibonacci


Vocabulary
random.lagged-fibonacci

Definition


Methods

M:: lagged-fibonacci random-float* ( lagged-fibonacci -- r )
lagged-fibonacci [ pt0>> ] [ u>> ] bi nth-unsafe
lagged-fibonacci [ pt1>> ] [ u>> ] bi nth-unsafe - dup 0.0 <
[ 1.0 + ] when [
lagged-fibonacci [ pt0>> ] [ u>> ] bi set-nth-unsafe
lagged-fibonacci [ adjust-ptr ] change-pt0 drop
lagged-fibonacci [ adjust-ptr ] change-pt1 drop
] keep ; inline



M:: lagged-fibonacci seed-random
( lagged-fibonacci seed -- obj )
seed normalize-seed seed! seed 30082 /i
:> ij seed 30082 ij * - :> kl ij 177 /i 177 mod 2 +
:> i! ij 177 mod 2 + :> j! kl 169 /i 178 mod 1 +
:> k! kl 169 mod :> l! lagged-fibonacci u>> [
drop
0.0 :> s! 0.5 :> t! 0.0 :> m! lagged-fibonacci-sig-bits
[
i j * 179 mod k * 179 mod m! j i! k j! m k! 53 l *
1 + 169 mod l! l m * 64 mod 31 > [ s t + s! ] when
t 0.5 * t!
] times s
] map! drop lagged-fibonacci p-r >>pt0 q-r >>pt1 ; inline