If you are doing programming, You must have used random numbers. They are useful in many situations when you want to give some randomization to your program output like lottery draw, random banners generation, random user display etc.
In PHP rand function is being used to generate random numbers, but is it really random number generator? Take a look at the following code.
< ?php
for($i=0;$1i<50;$i++)
{
print rand();
}
?>
What this function will do? If you are thinking that it will produce 50 random numbers, you just need to run this code. It is very likely that you will get the same number fifty times. Why rand function is not generating random numbers? Lets me introduce another function srand which is short for seed rand or seeding rand.
What is seeding? seeding in random number generation is they key to uniqueness. If you are not feeding a good seed to your random number generator, you are out of luck.
Why it is so difficult to implement random number generation algorithm?As per definition of algorithms, they are set procedures to solve a given problem. they can be repetitive and usually they are consistent in number of steps, in short they have a pattern. Random number on the other hand are supposed to break pattern. Random number generation is actually finding a pattern which should output a result which should break pattern. Thats why it is difficult.
Seeding is important to random number generation. Many algorithms even require more than one seed to do generate better random number.
In computer science, we are normally dealing with pseudorandom random numbers. Liner congruential generator also known as LCG is one of the oldest and best-known pseudorandom number generator algorithms