prand function
Return a random variable following a Poisson distribution of parameter z
.
Implementation
int prand(Random rand, double z) {
if (z <= 1.0e-10) {
return 0;
}
if (z > 100) {
return ((sqrt(z) * grand(rand)) + z).toInt();
}
var k = 0;
final y = exp(-z);
for (var s = 1.0; s >= y; ++k) {
s *= rand.nextDouble();
}
return k - 1;
}