[Tutor] A question on randomness

Gregor Lingl glingl@aon.at
Thu, 11 Jul 2002 23:29:35 +0200


----- Original Message -----
From: "Paul Sidorsky" <paulsid@shaw.ca>
To: "tutor" <tutor@python.org>
Sent: Thursday, July 11, 2002 10:19 PM
Subject: Re: [Tutor] A question on randomness


> Andrea Valle wrote:
>
> > But it seems to me that the code works as it often produces looping
patterns
> > (at least, they seem so to me): if the range is  0, 5, something like
> > 12312354542222 etc.
> > I know pseudo-random generation is a complex matter. Is there a way to
> > "improve" it? (I mean, to obtain a "good sequence" like 1432543122140133
> > etc.)
>
> I'm not an expert by any means but I have taken some University-level
> statistics, and to be quite honest I can't see any difference in those
> two examples.
>
> From what I can tell, you appear to be asking for avoiding long runs
> (like the 4 twos in a row) and clusters of numbers (like 123123).
> However, there's nothing out of the ordinary about getting repeating
> numbers or patterns of numbers.  If anything it probably means the
> random number generator is doing its job.  You can't complain if you
> know the dice are fair but you don't like the outcome.  :-)
> ....
> In a small sample there's nothing too out of the ordinary patternwise
> that I can see.  There's only one run of 4.  The odds of any run of 4
> are only 1 in 125.  Far far far more improbable things happen to all of
> us every day and we don't even notice.  :-)
>

Morover you should notice, that the probability to obtain 444 is ( or
should be) exactly the same as the probability to obtain 041
(for instance), as are the probabilities to obtain 12312354542222 and
14325431221401 respectively, or - if you are generating random sequences
of letters - the probabilities for QLLYX and TOSCA.

Gregor