Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fully initialize state when setting the seed (fixes #3) #7
So two things.
First, are we really sure that the
Second, what do mean by "extend the tests" (ie add more?) and by "unsure how it works"? We use the
See for example a use of seeding with the current CRAN version of the package, ie without your patch:
edd@brad:~$ Rscript -e 'library(RcppZiggurat); zsetseed(456); print(zrnorm(2)); zsetseed(789); print(zrnorm(2))'  -1.376230 -0.730005  0.1897669 -0.7272849 edd@brad:~$ Rscript -e 'library(RcppZiggurat); zsetseed(456); print(zrnorm(2)); zsetseed(789); print(zrnorm(2))'  -1.376230 -0.730005  0.1897669 -0.7272849 edd@brad:~$
We can set a seed perfectly well, and reproduce the results.
From my point of view
The first call reproduces your example. The second call shows that using the same seed '789' yields a different result if it is used as first seed. The third example shows that using the same seed multiple times within one R session gives different results (that was the original issue from SO). This is different from base functionality:
With the patch applied, I get reproducible random numbers that are independent of the RNG's history:
I will extend the PR w.r.t
Let me think about this:
My gut reaction is that this is simply how Ziggurat works / is designed.
But your third example is good. I think I may have tried to be too-clever-by-half and have the assignment your PR brings already in the class so that it happens at instantiation. What I overlooked was the reset-during-session functionality your third examples shows. I am warming up to this. But still early-ish morning here :)
Take your time. :-) Just one more detail. I do not think that this is specific to the Ziggurat method, since ZigguratLZLLV behaves the way I am expecting (and also sets