number generator

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Sun Mar 11 00:26:12 EST 2007


On Sat, 10 Mar 2007 16:02:56 -0800, Paul Rubin wrote:

> Steven D'Aprano <steve at REMOVE.THIS.cybersource.com.au> writes:
>> > By your method, what is the probability of the first number being
>> > higher than 30?  What is the probability of the fifth number being
>> > higher than 30?  If these probabilities are unequal, can we really say
>> > the sequences are random?
>> 
>> Of course we can! "Uniform probability distribution" is a special case of
>> random. Most random quantities are far from uniform. The Python random
>> module includes a couple of non-uniform distributions, including
>> exponential distribution (random.expovariate) and the famous bell curve
>> distribution (random.normalvariate).
> 
> Ehh.  Say we call some generator repeatedly and get back the sequence
> (3, 3, 3, 3, 3, ...).  Would we say this is a random sequence using a
> distribution that puts 100% of the probability density at 3?  Or would
> we just say it isn't random?

Oh! You know that bit where I said that every imaginable sequence of
integers was random? I take it back.

Oh wait. I never said anything of the sort. Not every sequence of ints is
a random sequence.

Although... your question is deeper than it appears at first glance. In
any truly random sequence, you should expect to find repeated values. If
you wait long enough, you should get a sequence of 3,3,3... for any number
of threes you like. (Or, naturally, any other integer.) If you wait long
enough, you should get a billion threes.



-- 
Steven.




More information about the Python-list mailing list