Initialize carry using lcg instead of modulo divide seed
This commit is contained in:
parent
9417d6ffdc
commit
d326e45b32
@ -22,8 +22,6 @@ class CMWCRandom(seed: Long = System.nanoTime()) : RandomGenerator, RandomSource
|
||||
|
||||
override fun setSeed(seed: Long) {
|
||||
this.seed = seed
|
||||
carry = Integer.remainderUnsigned(seed.toInt(), CMWC_CARRY_MAX)
|
||||
|
||||
var lcg = seed
|
||||
|
||||
// init state with regular LCG produced values
|
||||
@ -32,6 +30,11 @@ class CMWCRandom(seed: Long = System.nanoTime()) : RandomGenerator, RandomSource
|
||||
state[i] = lcg.ushr(32).toInt()
|
||||
}
|
||||
|
||||
do {
|
||||
lcg = lcg * 6364136223846793005 + 1442695040888963407
|
||||
carry = lcg.ushr(32).toInt()
|
||||
} while(carry !in 0 until CMWC_CARRY_MAX)
|
||||
|
||||
stateIndex = state.size - 1
|
||||
gaussian.reset()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user