Open
Description
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.
Metadata
Metadata
Assignees
Labels
No labels