On Tue, 6 Dec 2022 at 14:00, James Johnson <jj126...@gmail.com> wrote:
>
> I came back to this thread looking for the list of randomness tests, and I 
> keep missing them somehow.
>
> The reason for my follow up is this: The random number function in Python has 
> important uses far beyond my personal concerns, and random.randint(0,9) is 
> supposed to be the Mersenne Twister.
>
> I used the attached code to generate the attached file. It’s randint(0,9) for 
> n=600, keyed back in by hand, instead of automatically from the script:
>
> My question/concern is this: does this dataset look like it came from the 
> Mersenne Twister? In 600 iterations, it generated 8,8,8; 0,0,0; 1,1,1 and 
> 5,5,5, with more than 1% (6) occurrences where the same number repeated. I 
> didn't do the +1/-1 test, but the data is in a (python) list that should be 
> easily cut and pasted into a legit datafile.
>

Let's see. What are the odds of getting three consecutive digits?
First digit could be anything, so that's 1/1; second digit is 1/10,
third digit is 1/10. So for any given set of three random decimal
digits, there's a 1% chance that they're all the same. In 600 rolls,
there are 598 triples (since you could start a triple at any point),
but they're not entirely independent. I'd have to do some serious
number crunching to determine the exact probabilities involved, but
the expected number of triples has to be somewhere between 1% of 200
(counting only those that completely don't overlap) and 1% of 598
(counting everything, regardless of overlap), or somewhere between 2
and 5.98. You got four of them, so without a ton of number crunching,
I'd say that that's at least reasonably plausible. Or if I've misread
you and you got six of them, that's still right on the edge of the
expected range, and the chances of that happening are still quite
reasonable.

Calculating the probability of seeing six triples is actually quite
complicated and I really don't want to go into the details, but I
would recommend just trying on a larger pool of numbers.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/S5QLDNTTDH6V2SASBRY32HS33BSN5PGU/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to