More problems with random seed (was Re: whrandom seed question)
Al Christians
achrist at easystreet.com
Wed Nov 24 16:20:59 EST 1999
Stelios Kyriacou wrote:
>
> Why when I call the gauss distribution I get 2 alternating values:
>
> >>> random.seed(0); print random.gauss(0,1);
> 2.11224018067
> >>> random.seed(0); print random.gauss(0,1);
> 0.225551631579
> >>> random.seed(0); print random.gauss(0,1);
> 2.11224018067
> >>> random.seed(0); print random.gauss(0,1);
> 0.225551631579
> >>> random.seed(0); print random.gauss(0,1);
> 2.11224018067
> >>>
>
> Any more ideas?
Surprisingly:
>>> random.seed(0)
>>> random.gauss(0,1) / random.gauss(0,1)
Gives me either 0.106783136522 or 9.36477455684
And, astoundingly (???):
>>> 9.36477455684 * 0.106783136522
1.0
Not really, according to Numerical Recipes, etc, random gaussian's are
generated in pairs. One is saved for next time. The random.seed()
function must not be clearing out the cached value.
Should it?
Al
More information about the Python-list
mailing list