Inspired by General purpose random number generation I decided to perform my own tests to see what was wrong with rand(). Using this program:
srand(time(0));
for (int i = 0; i < 1000000; ++i)
{
std::cout << rand() % 1000 << " ";
}
I loaded it up in Octave using the commands:
S = load("test.txt")
hist(S)
And got this result:
To me the results seem to be pretty uniform. I expected the results to be more skewed. Did I conduct my test wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…