通过泊松过程生成到达时间并不意味着使用泊松分布。它是通过创建基于泊松到达率 lamda 的指数分布来完成的。
简而言之,您需要生成一个平均值 = 1/lamda 的指数分布,请参见以下示例:
#include <iostream>
#include <iterator>
#include <random>
int
main ()
{
// seed the RNG
std::random_device rd; // uniformly-distributed integer random number generator
std::mt19937 rng (rd ()); // mt19937: Pseudo-random number generation
double averageArrival = 15;
double lamda = 1 / averageArrival;
std::exponential_distribution<double> exp (lamda);
double sumArrivalTimes=0;
double newArrivalTime;
for (int i = 0; i < 10; ++i)
{
newArrivalTime= exp.operator() (rng); // generates the next random number in the distribution
sumArrivalTimes = sumArrivalTimes + newArrivalTime;
std::cout << "newArrivalTime: " << newArrivalTime << " ,sumArrivalTimes: " << sumArrivalTimes << std::endl;
}
}
运行此代码的结果:
newArrivalTime: 21.6419 ,sumArrivalTimes: 21.6419
newArrivalTime: 1.64205 ,sumArrivalTimes: 23.2839
newArrivalTime: 8.35292 ,sumArrivalTimes: 31.6368
newArrivalTime: 1.82962 ,sumArrivalTimes: 33.4665
newArrivalTime: 34.7628 ,sumArrivalTimes: 68.2292
newArrivalTime: 26.0752 ,sumArrivalTimes: 94.3045
newArrivalTime: 63.4728 ,sumArrivalTimes: 157.777
newArrivalTime: 3.22149 ,sumArrivalTimes: 160.999
newArrivalTime: 1.64637 ,sumArrivalTimes: 162.645
newArrivalTime: 13.8235 ,sumArrivalTimes: 176.469
因此,根据您的实验,您可以使用:newArrivalTime 或 sumArrivalTimes。
参考: http: //www.math.wsu.edu/faculty/genz/416/lect/l05-45.pdf