On Tue, 15 Nov 2022 at 01:34, James Johnson <jj126...@gmail.com> wrote: > > I wrote the attached python (3) code to improve on existing prng functions. I > used the time module for one method, which resulted in disproportionate odd > values, but agreeable means. >
Current time of day is NOT random, and the low bits depend wildly on the available computer clock. Many (all?) computer clocks today do not have actual nanosecond resolution, so taking just the low bits in this way is going to give badly skewed values. > I used the hashlib module for the second. It is evident that the code is > amateur, but the program might result in better PRN generation. Hashing is a known way to improve the distribution of random numbers, but it doesn't add entropy. You need to first have actual entropy to work with. > The "app" lends itself to checking, using statistical tools (see comments.) Averages are only one possible test for random distribution. Here are a bunch more: https://calmcode.io/blog/inverse-turing-test.html Try your random number generation there, and see how random it truly is. In what way is your code better than current? 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/HUPNIJYPSIYO2PDSHYGHJGA2FNSGVACU/ Code of Conduct: http://python.org/psf/codeofconduct/