We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
double rand_float() { return rand() / (static_cast(RAND_MAX)); }
double rand_float(float min, float max) { return (max-min)*rand_float()+min; }
int rand_int(int min,int max) { return (rand() % (max-min)) + min; }
These functions in /simplega/helpers.cpp can give non-uniformity because of modding by an integer (see http://channel9.msdn.com/Events/GoingNative/2013/rand-Considered-Harmful for details as to why).
Proposition: use std::uniform_int_distribution and std::uniform_real_distribution to shape the random integers/floats being generated.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
double rand_float()
{
return rand() / (static_cast(RAND_MAX));
}
double rand_float(float min, float max)
{
return (max-min)*rand_float()+min;
}
int rand_int(int min,int max)
{
return (rand() % (max-min)) + min;
}
These functions in /simplega/helpers.cpp can give non-uniformity because of modding by an integer (see http://channel9.msdn.com/Events/GoingNative/2013/rand-Considered-Harmful for details as to why).
Proposition: use std::uniform_int_distribution and std::uniform_real_distribution to shape the random integers/floats being generated.
The text was updated successfully, but these errors were encountered: