|
let __default_state = Random.State.make_self_init () |
here an internal __default_state is created with a random seed, which is later used by default in the run functions. this default state is different from the one in the included Stdlib.Random module, namely Random.default, afaict. i came across this because i encountered non-reproducible simulation runs.
i worked around it by always calling run ~st:(Random.get_default_state ()) which copies the default state from Stdlib.Random, which i make sure to initialized in a reproducible way. i think this copying costs performance; a better way would be to create, initialize and later supply my own random state to give to the ~st argument of run.
anyway, i don't quite understand why CCRandom does not reuse the default state in Stdlib.Random? that way, Random.init would make CCRandom.run with default state reproducible, iiuc.
ocaml-containers/src/core/CCRandom.ml
Line 207 in 447df82
here an internal
__default_stateis created with a random seed, which is later used by default in therunfunctions. this default state is different from the one in the includedStdlib.Randommodule, namelyRandom.default, afaict. i came across this because i encountered non-reproducible simulation runs.i worked around it by always calling
run ~st:(Random.get_default_state ())which copies the default state fromStdlib.Random, which i make sure to initialized in a reproducible way. i think this copying costs performance; a better way would be to create, initialize and later supply my own random state to give to the~stargument ofrun.anyway, i don't quite understand why
CCRandomdoes not reuse the default state inStdlib.Random? that way,Random.initwould makeCCRandom.runwith default state reproducible, iiuc.