What is the logic to generate random numbers in a computer program?
Randomness implies that there is no pattern in the occurence. When you program something to spit out random numbers, you are programing some kind of logic flow in that code aren't you? Does it make it random anymore?
Public Comments
- A lot of random number programs use the clock on the computer. So it draws the time and developes the number off that. There are many problems ith that though because they tend to be repetitive over time. Hope that helps!
- The short answer to this is: computers can not create random numbers. The long answer requires several days of reading, some understanding of maths and some physics... and a lot of boredom.
- Computers that use algorithms to generate "random" numbers are as you observe not truly random. These are generally called "pseudo-random numbers." The test of goodness is whether the values are detectably non-random. That is, if you can't find a pattern, do you need to care that the values are not truly random? However, with sufficiently sensitive analysis, you can detect non-random behavior in most such algorithms. The short answer is "no -they are NOT random." One of th simplest of algorithms is called "linear, congruential, random number generator." They're the easiest to program, if a bit dated. Look 'em up online, if you're still interested.
- Programs generally use time to generate random numbers. You can use math to define the scope of the random numbers. But the numbers are still random because you don't know what number it's going to choose. I actually created a program that assigned people to random seats on an airplane. the assignments were different everytime.
- Here's the "big" secret... Inside your computer, there is a little guy with a hat - and ten slips of paper (with the numbers 0-9 on them). Everytime a program asks for a random number, the CPU (which he uses as a bed) becomes electrified - and shocks the guy in the @$$. He takes off his hat, throws in the numbers, and pulls one out. With a loud angry yell, he bellows out the number for all to hear - and the program fairies tell the computer itself what number he picked, and it displays it on the magic screen ;););););)
Powered by Yahoo! Answers