icecube / flarestack

Unbinned likelihood analysis code for astroparticle physics datasets
https://flarestack.readthedocs.io/en/latest/?badge=latest
MIT License
8 stars 7 forks source link

Use global rng in NTSeason.simulate_background #395

Closed jvansanten closed 1 week ago

jvansanten commented 1 week ago

NTSeason.simulate_background() instantiates a fresh RNG each time it is called, using entropy from the system, whereas most (all?) of the rest of flarestack uses the global RNG numpy.random. Use the global RNG instead, so that MinimizationHandler.prepare_dataset() setting of the global seed has the intended effect.

mlincett commented 1 week ago

Indeed.

I think this was my choice because at the time I thought we would transition to default_rng() everywhere (see #129).

Clearly that does not work well for reproducibility unless the global seed is propagated to individual RNG objects (that can become cumbersome). But in that case the RNG should be an attribute of the object, and not be recreated at every call of the method.

Sorry this caused (unexpected) trouble. I am fine with the workaround as it seems the path of least friction.