Showing posts with label Randomness. Show all posts
Showing posts with label Randomness. Show all posts

Wednesday, April 6, 2011

When Random Isn't Random Enough

  For anyone who has done a bit of programming, there is a good chance that you've had to use random numbers. They can been very helpful for simulating the chaotic events we need for experiments or programs, such as basic AI for a game or natural events. But an important thing to know about most random numbers generated by a computer are not random at all but psudorandom.
  Random numbers generated by a computer require a seed, or some number put into an algorithm to produce the random number. This seed can come from many different places depending on the random number generator. The most basic generator uses a static number each time, producing the same exact string of random numbers each time, not very random. The next step up uses the system clock to pull the current time based in seconds from midnight of January 1, 1960. This is a decent way to to "randomize" the seed, but numbers generated within the same second pull from the same seed, which may cause problems. Other random number generators use chaotic inputs from the user to determine seeds, such as mouse movements or keyboard inputs. Mike Ash has a good blog post about the different tiers of random number generators here.
  If you desire true random numbers, then look no farther than Random.org. At Random.org, they use atmospheric noise to generate random numbers in a variety of forms, from simple integers to die rolls or cards drawn from a deck. They also have a very good piece detailing psudorandom number generators and how they compare with true random number generators. You could always use it to generate your passwords or choose your next vacation spot, probably better than throwing darts at a map.