random number generator issue
Posted: Thu Aug 12, 2021 11:29 pm
I was doing some simulations, and using the random() function, and got some results that I doubted. To do a quick test, I wrote the following simple test, and got these results on several successive runs:
997,997,997,996,998,991,997,997,996,995
1050,1048,1048,1051,1053,1047,1054,1053,1052,1051
1005,1003,1006,1004,1003,1005,1004,1002,1006,1006
934,933,934,934,934,935,930,933,931,931
As you can quickly see, none of these sets of 10 numbers add up to 10,000. This implies to me that some of the random numbers are being placed somewhere other than the item in the list where is should be.
Does this make any sense? How can I trust the random number generator at all??
997,997,997,996,998,991,997,997,996,995
1050,1048,1048,1051,1053,1047,1054,1053,1052,1051
1005,1003,1006,1004,1003,1005,1004,1002,1006,1006
934,933,934,934,934,935,930,933,931,931
As you can quickly see, none of these sets of 10 numbers add up to 10,000. This implies to me that some of the random numbers are being placed somewhere other than the item in the list where is should be.
Does this make any sense? How can I trust the random number generator at all??
Code: Select all
on mouseUp
get 10
repeat with i = 1 to 1000 * it
add 1 to item (random (it)) of tList
end repeat
put tList
end mouseUp