I have thought of a new concept that I may launch soon. However, it will rely on a random number generator (or something similar) to function properly. Does anyone know of a reliable one to download or use? How reliable are they? truly random? Thanks
You can never have truly random numbers on a computer. They are pretty damn random to the casual viewer, but mathematically they are not. Not sure if that means anything to you or not. If you have *nix hosting you can use the command line command "random", or just use PHP's random function or something. Really depends on what you need it for and what you expect as far as "reliability" goes?
I guess as long as it gives the appearance of random to the user it would suit my needs...but I'd rather not get sued As long as no one knows that its not 'truly' random then it wouldn't matter... Thanks for the help!
An important part of generating a random number is the seed value. Some libraries now try to start the generator with something other than just time to get a more random result. If you use time and the generator is called at the same instant, the same number could be generated for each individual and the same second number and so forth. Some people have tried to get around this by looking for other data to help generator a more random seed, combining time with process ID numbers and/or free memory and/or some other data bits readily available from the host computer. Internet applications could use time plus IP addresses as a seed value -- though this breaks down if two people from same IP access the application at the same moment. It is an interesting topic and many people have worked on the science of generating better random numbers. A search will yield innumerable articles on the topic and ideas for ensuring a more unpredictable random number is generated . . . especially if you are worried about legal liability.
If you really want random numbers, you can make something that connects to http://www.random.org/nform.html to get a list of random numbers.
Most Unix like operating systems have special device name for the stream of high quality random numbers, but this stream is rather slow sometimes, thus for the most purposes it would be best to use its output as a seed for the pseudo random numbers generator. /dev/random
And the best generator of the pseudo random numbers which I know of is the Mersenne Twister, a very fast pseudo random number generator of period (2^19937)-1. http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
As Artisan said, most random number generators are actually pseudo random number generators. It's been a while since I've had my head buried in the guts of random generators (did lots of work with this stuff years ago at a very low level), but IIRC... Most common/popular random number generators are of the "linear congruential generator" (or LCG for short) variety, and these do have a certain periodicity, meaning that in time the pseudo-random sequence will roll over and start to repeat itself. The peridocity and other factors of an LCG are known up front, based on the LCG algorithm itself and the initial input parameters. You can determine the quality of a random number generator by seeing how well it truly does generate random number by using various statistical "goodnes of fit" tests. Two common tests for random number generators (assuming you know the distributions) are the chi-squared test and the kolmogorov-smirnov test (no relation to the vodka dude). Simulation Modelling and Analysis by Law & Kelton has excellent coverage of random generators and goodnes-of-fit tests. If you don't want to go the dead tree route, Google the terms "LCG generator" "chi squared test" and "kolmogorov smirnov" (not all at once). Those should get you going.