Do you know where your variables are? | |
PerlMonks |
Re^4: JAPH randomnessby awwaiid (Friar) |
on Feb 03, 2005 at 15:23 UTC ( [id://427672]=note: print w/replies, xml ) | Need Help?? |
*BIG SMILE* Welcome, my friend, to the world of pseudo-random number generators! One of the best things about computers is that they are (supposed to be) deterministic; so random number generators are based on neat mathematical equations which appear random to an observer. You start with a seed, and then each number generated is based on the number(s) which have already been generated, going back to the seed. Now, not all of these pseudo-random number generator algorithms are as "random" as others (see Knuth's work for example). Not long ago I had a Commodore-128 on which I was doing some lottery simulations and statistics to see if I could predict the lottery. I got stunningly good results... but as it turns out it was a weakness in the built-in random-number generating algorithm, not a weakness in the lottery :) In any case, one thing that most of the pseudo-random number generators have in common is the seed. You give it the same seed, you get the same sequence of random numbers. All sorts of fun follow that. If you don't specify the seed one is created for you, based off of timing-based things like the clock and the PIDs and things like that (see function srand) Our pseudo-random number generating days are most certainly limited, however. Hardware-based random number generators are increasingly innexpensive, and I doubt it will take long before all devices which need a random-number (all desktops for example) have one built-in. These are based on random numbers generated from physics... sort of the opposite of the timing accuracy of your quartz watch. Some are even based on magical quantum physics stuff... I love living in the future!
In Section
Obfuscated Code
|
|