Hi, I don't understand the need for the while statement. Any help would be greatly appreciated.
double michel()
{
double x, y;
do // The loop computes points on the graph of y against x.
{
x = 53.0*rand()/RAND_MAX; // x is the momentum. x is randomly generated. Min x is 0 MeV/c. Max x is 53 MeV/c.
y = x/53.0; // y is the probability distribution function. Min y is 0. Max y is 1.
} // y is a triangular distribution. Hence, y = (1/53)*x.
while (1.0*rand()/RAND_MAX > y); // Because we want to start with the WHYYYYYYYYYYY????????????
return x;
}