I want to sample a series of random numbers from Poisson distributions, such as
using Distributions, Random
Random.seed!(1)
rand(Poisson(10)) # 9
rand(Poisson(11)) # 12
rand(Poisson(12)) # 9
rand(Poisson(13)) # 17
I would then like to be able to change some values in this sequence, but have unchanged lines return the same result as before:
Random.seed!(1)
rand(Poisson(10)) # 9
rand(Poisson(20)) # 22
rand(Poisson(12)) # 9
rand(Poisson(13)) # 17
However, if any values >=6 switch to <6, or vice versa, then this disrupts the seed for subsequent values:
Random.seed!(1)
rand(Poisson(10)) # 9
rand(Poisson(5)) # 2
rand(Poisson(12)) # 16
rand(Poisson(13)) # 13
I have traced the source of this difference to line 138 of Distributions.jl/src/univariate/discrete/poisson.jl at master · JuliaStats/Distributions.jl · GitHub, where different samplers are used on different sides of poissonsampler_threshold = 6
.
Is there a way to have the unchanged lines return the same value regardless of whether other lines switch around this threshold?