[Alec Henriksen]
> How trustworthy is the "randomness" generated by the random module?
Python uses the Mersenne Twister algorithm for generating
pseudo-random numbers, and that's one of the highest-quality methods
known. You can read more about it, e.g., here:
http://en.wikipedia.org/wiki/Mersenne_Twister
> I just wrote a script (with the help of some tutors here!) that finds
> the largest streak in a series of coin flips.
>
> My collected data:
>
> 100 coin flips = 6-7 streak (usually)
> 1000 coin flips = 10-12 streak (usually)
> 10000 coin flips = 15-19 streak (usually)
> etc etc.
>
> I'm curious, how much can I trust the randomness?
For this purpose, you can have high confidence -- provided your
program is correct ;-)
> I can't really do 100000 coin flips in real life to compare...
The theoretical expected maximum run length is given by equation (15)
here, with p=0.5 and n=100000:
http://mathworld.wolfram.com/Run.html
although I'm not certain that coincides with what you mean by "streak".
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor