Testing random

Chris Angelico rosuav at gmail.com
Sun Jun 7 14:52:06 EDT 2015


On Mon, Jun 8, 2015 at 4:23 AM, Thomas 'PointedEars' Lahn
<PointedEars at web.de> wrote:
> If the set to choose from is integer numbers from 1 to 9, then *each* of
> those sequences has *the same* probability (1∕9)¹¹ ≈ 3.1866355 × 10⁻¹¹.
>
> AISB, those are *independent* events; the number of occurrences of an
> outcome before *does not matter* for the probability of the next one.  And
> so the probability of getting a certain number does _not_ change depending
> on the number of times you repeat the experiment.  It is always the same;
> in this example, it is always 1∕9.  And the probability of _not_ getting a
> certain number is always the same; in this example, it is always 1 − 1∕9 =
> 8∕9.

Yes, the probability of not getting a certain number is always 8/9...
but the probability of not getting that number for an entire sequence
is 8/9 raised to the power of the length of the sequence, because they
are independent events that must *all* happen. In your case, with a
length of 11, that means there's about a 27% chance of any particular
number not happening. Looking at it the other way, that means there's
a 73% chance of seeing at least one N, for any N. So the probability
of seeing at least one of every digit is actually quite low - about
5.6% - because you're looking for nine digits out of eleven. (Note
that the numbers aren't quite exact here. The probabilities aren't
entirely independent. Calculating off the exact figures is left as an
exercise for the reader, but I don't expect they'll be more than a
percentage point different one way or the other.)

The chances of not seeing a 5 in any of 100 tosses would be virtually
nil. The chances of not seeing a 5 in any of 1000 tosses is so close
to zero that its inverse is indistinguishable from certainty with
Python floats (IEEE double precision):

>>> 1.0-(9/10)**1000 == 1.0
True

That's a pretty low number.

ChrisA



More information about the Python-list mailing list