我想生成一个泊松过程.如果按时间 t 到达的次数是 N(t),并且我具有参数为λ的泊松分布,如何生成 N(t)?我将如何在C ++中做到这一点?
说明:我本来想使用泊松分布来生成过程.但是,我对于需要从流程中获取什么参数感到困惑;我以为我可以使用 N(t),但这告诉我在间隔(0,t] 上有多少次到达,这不是我想要的.那么我以为我可以使用 N(t2)-N(t1)来获取间隔 [t1,t2] 上的到达次数. t)〜Poisson(txλ)我可以使用 Poisson(t2 xλ)-Poisson(t1 xλ),但我不希望间隔内到达的数量./p>
相反,我想生成到达发生的明确时间.
我可以通过使间隔 [t2,t1] 足够小,以使每个间隔只有一个到达(发生为 | t2-t1 |-> 0 ).
解决方案此处是使用 C ++ TR1 .
如果需要泊松过程,则两次到达之间的时间呈指数分布,并且可以使用逆CDF方法简单地生成指数值:-k * log(u),其中u是均匀随机数变量,k是指数的平均值.
Original Question:I want to generate a Poisson process. If the number of arrivals by time t is N(t) and I have a Poisson distribution with parameter λ how do I generate N(t)? How would I do this in C++?
Clarification:I originally wanted to generate the process using a Poisson distribution. But, I was confused about what parameter from the process I needed; I thought I could use N(t) but that tells me how many arrivals have occurred on the interval (0,t] which wasn't what I wanted. So, then I thought I could use N(t2)-N(t1) to get the number of arrivals on the interval [t1,t2]. Since N(t)~Poisson(t x λ) I could use Poisson(t2 x λ)-Poisson(t1 x λ) but I don't want the number of arrivals in an interval.
Rather, I want to generate the explicit times that arrivals occur at.
I could do this by making the interval [t2,t1] sufficiently small so that each interval has only one arrival (which occurs as |t2-t1| -> 0).
解决方案Here's sample code for generating Poisson samples using C++ TR1.
If you want a Poisson process, times between arrivals are exponentially distributed, and exponential values can be generated trivially with the inverse CDF method: -k*log(u) where u is a uniform random variable and k is the mean of the exponential.