I saw a video on YouTube recently about generating random numbers, and the fellow who talked about it gave a formula for generating numbers that depend on human input but look random. The forumla was as follows:
(a * x + b)%m
A, x, and b are numbers that the human behind the computer puts in. The “%m” part is modulo division, so you divide the ax+b part by m, your maximum number, and the remainder is your result. For more “random” numbers that really just look more random, you take the result of that formula and replace it with x. I experimented with this in Applescript, and came up with this:
try
set a to text returned of (display dialog "Set a variable." default answer "300" default button 2) as integer
set x to text returned of (display dialog "Set another variable." default answer "7" default button 2) as integer
set b to text returned of (display dialog "Set a third variable." default answer "13" default button 2) as integer
set m to text returned of (display dialog "Set a maximum." default answer "10" default button 2) as integer
display dialog (a * x + b) mod (m)
on error
display dialog "There was an error in process of generating your psuedorandom number. Please try again."
end try
If you rerun it and put x as the result, again your numbers will look more random. But, since there is a formula, nothing in this is really random.
Logically, m happens to be your maximum number because the remainder of a division cannot be more than the divisor, so play with that.
And, if you run the program several times with the defaults I set, you will always end up with the answer of 3. This is proof that the numbers aren’t really random.
Anybody can use my program anywhere. Thanks for viewing,
That’s interesting how a simple formula could generate pseudorandom numbers. Why would you use this instead of better random number generators? I’m thinking that there might be a reason.
But aside that, apparently there is no such thing as a “random” number from a computer. All “random” numbers have a formula behind them, or so the video I saw says.
Actually there is a random number. How to get it is hard. If I’m remembering right, it had something to do with the uncertainty principle. I think that was something you could not predict.
In the video I saw, the people in the video actually generated a completely random number by taking the deviation from the mean in terms of electrons released from decaying Strontium. I don’t know how to do it on a computer though.
I am not going to argue whether random numbers exist or not.
You may find it interesting in looking into hashing algorithms, which relies heavily upon random numbers (pseudo :)), there is a slew of cryptographic algorithms which also may be worth while to look into. (Wikipedia for both). sha1, and aes should be interesting to look at while studying random numbers. And just for fun of course. Random numbers are fun!
Another interesting beast, is the Chinese Reminder Theorem.
The time resolution of random number generators are so precise and the machine is controlled by human hand, of course it feels like an true random number. It is actually our randomness in time controlling the computer that generates the random number, not the computer.