From rand.inc included in povray 3.6 (the same as in 3.5 actually):
// Poisson distribution
// Input: Mu= mean and a random stream.
#macro Rand_Poisson(Mu, Stream)
#local Maxtimes = 100000; //just to be sure
#local Cut=exp(-Mu);
#local N=0;
#local R=1;
#while (R>=Cut)
#local R=R*rand(Stream);
#local N=N+1;
#if(N>Maxtimes)
#local R=Cut;
#end
#end
(N)
#end
In the #while line there should be (R>Cut) and not (R>=Cut), because
1. according to some book.
2. values of Mu>=24 produce infinite loops (at least on linux).
Post a reply to this message
|