Creating a more random int?

Magnus Lycka lycka at
Wed Jan 25 09:40:10 EST 2006

Steven D'Aprano wrote:
> But all joking aside, the random number generator used by Python is one of
> the best in the world. What is at fault is your intuition about what
> random numbers should look like, not the random number generator.

This is a well known problem, and there are methods to detect
"too good to really be random" results in both research and
accounting, based on statistical analysis of the numbers.

The only thing the original poster really needs to understand
is that chance has no memory. If you roll a dice, and it's not
loaded, the chance that it will show a particular value is
always one in six. All values are as likely. It doesn't matter
that you've rolled 6 five times in a row. The change that the
dice will come up with a 6 a 6th time is is still 1/6. I.e.
it's as likely as any other particular value. Ten sixes in a
row is just as likely as any other sequence of numbers. The
chance for any sequence to occur is 6**-10.

Die rolls are not like drawing cards from a deck of cards, where
there are fewer queens left once we've drawn a queen.


P.S. Since I was a kid, I've heard people say: So you're born
on new years day--how unusual. Sigh... We humans have a very
good ability to spot things that seem to stick out from the
ordinary, such as dates that look particular, or the number
7 popping up thrice in a row. We also need to realize that,
while these things that stick out help us find significant
things, there are also a lot of "false positives"...

More information about the Python-list mailing list