In the following code, how RAND_MAX works and how the poisson distribution value generated???
what will be the value of RAND_MAX in following code??
long poisson(double lambda)
{
double u = double(rand()) / RAND_MAX;
long k = 0;
double currentprob;
while (u >= (currentprob = pow(lambda,k) * exp(-lambda)
/ factorial(k)))
{
u -= currentprob;
k++;
}
return k;
}