I am reading a book and it has this function. I do not understand what is the usage of using rand()/(RAND_MAX), doesn't it just produce a random ratio value? How can we use a random ratio value to check whether it is larger than the exponential?
#include <cmath>
bool isCustomerArrived(double arvTimeDiff)
{
double value;
value = static_cast<double> (rand()) / static_cast<double>(RAND_MAX);
return (value > exp(- 1.0/arvTimeDiff));
}
Aucun commentaire:
Enregistrer un commentaire