Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: random numbers




On 2025-09-15 20:10, Lawrence Velázquez wrote:
RANDOM % 10 produces the ones digit of the decimal number RANDOM.
In the closed interval [0, 32767], each of 0 through 7 occurs as
the ones digit in 3277 integers, while 8 and 9 each occurs in 3276
integers.
Thanks.  Not too complicated after all.
The uniform distribution doesn't follow Benford's law.

https://pmc.ncbi.nlm.nih.gov/articles/PMC2866333/#s3
Looks over my head but will read.  I think I understand it intuitively: the difference between 1 and 2 is much bigger than between 8 and 9 in terms of ratio of change.  At higher digits one 'risks' flipping the odometer to an additional digit, which will of course be very likely to be 1.  Needs work.  Anyway it's established that RANDOM is not applicable.
Probability can be very subtle, and it's hard to be sure you're
doing things right.  I'm no expert myself.
I've been aware of that in principle for a long time but this is my first hard experience of it, at least as far as RANDOM goes.  Quite fascinating that something that sounds so simple and so easy is anything but.  Humans can be erratic, but never random.  Thank you Sensei.





Messages sorted by: Reverse Date, Date, Thread, Author