I read that rand should not be used for serious statistical purposes. Does anyone have an explanation for this point of view? What are more suitable alternatives?
If you want better, look at Boost's random number library, or perhaps randomlib (nice interface for a Mersenne twister). There are many more; google will present lots.
It is implementation specific. The standard does not specify anything beyond "The rand function returns a pseudo-random integer."
It gives this as a possible implementation, so you can see the potentially shoddy quality of random numbers you might get out of calling rand(). :)
1 2 3 4 5 6 7 8 9 10 11 12
staticunsignedlongint next = 1;
int rand(void)
// RAND_MAX assumed to be 32767
{
next = next * 1103515245 + 12345;
return (unsignedint)(next/65536) % 32768;
}
void srand(unsignedint seed)
{
next = seed;
}