forum.alglib.net
http://forum.alglib.net/

invpoissondistribution
http://forum.alglib.net/viewtopic.php?f=2&t=527
Page 1 of 1

Author:  CP2587 [ Thu Jan 26, 2012 12:07 am ]
Post subject:  invpoissondistribution

Hi everyone,

I use alglib as a random number generator and ,in particular, i am working with the function invpoissondistribution to simulate a random variable following a poisson.
However, with this piece of code,
{
double Demand[1000];
double mean(0);
for(int i(0);i<1000;i++)
{
Demand[i]=invpoissondistribution(40,randomreal());

mean=Demand[i]+mean;
}
return mean/1000;
}

I get that the mean is approximately 41 (41.15 exactly). How is that possible when the mean should be 40 ? What do I miss ?

Thanks,

Author:  Sergey.Bochkanov [ Fri Jan 27, 2012 5:37 am ]
Post subject:  Re: invpoissondistribution

Asymptotic mean should be 40, but finite-sample mean can deviate from asymptotic value with average error roughly proportional to 1/sqrt(sample_size). If you increase sample size from 1000 to 100000 you should see ten times smaller error.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/