我实现了这个函数来生成poisson随机变量
I implemented this function to generate a poisson random variable
typedef long unsigned int luint; luint poisson(luint lambda) { double L = exp(-double(lambda)); luint k = 0; double p = 1; do { k++; p *= mrand.rand(); } while( p > L); return (k-1); }其中mrand是MersenneTwister随机数生成器。我发现,当我增加lambda,预期分布将是错误的,一个平均值饱和在750左右。是由于数字近似还是我犯了什么错误?
where mrand is the MersenneTwister random number generator. I find that, as I increase lambda, the expected distribution is going to be wrong, with a mean that saturates at around 750. Is it due to numerical approximations or did I make any mistakes?
推荐答案从 poisson(750)为 poisson(375)+ poisson(375)。