模拟泊松等待时间 [英] Simulating Poisson Waiting Times

查看:123
本文介绍了模拟泊松等待时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要模拟泊松等待时间。我发现了许多模拟到达次数的例子,但我需要模拟一次到达的等待时间,给定平均等待时间。

I need to simulate Poisson wait times. I've found many examples of simulating the number of arrivals, but I need to simulate the wait time for one arrival, given an average wait time.

我一直在查找代码像这样:

I keep finding code like this:

public int getPoisson(double lambda) 
{   
    double L = Math.exp(-lambda);   
    double p = 1.0;   
    int k = 0;   

    do 
    {    
        k++;     
        p *= rand.nextDouble(); 
        p *= Math.random(); 
    } while (p > L);   

    return k - 1; 
} 

但这是抵达人数,而不是抵达时间。

but that is for number of arrivals, not arrival times.

效率优于精确度,更多是因为功耗比时间。我正在使用的语言是Java,如果算法只使用Random类中可用的方法,那将是最好的,但这不是必需的。

Efficieny is preferred to accuracy, more because of power consumption than time. The language I am working in is Java, and it would be best if the algorithm only used methods available in the Random class, but this is not required.

推荐答案

到达之间的时间是指数分布,您可以使用以下公式生成随机变量 X~exp(lambda)

Time between arrivals is an exponential distribution, and you can generate a random variable X~exp(lambda) with the formula:

-ln(U)/lambda` (where U~Uniform[0,1]). 

关于生成指数变量

请注意,到达之间的时间也与首次到达之前的时间相匹配,因为指数分布为< a href =http://en.wikipedia.org/wiki/Exponential_distribution#Memorylessness =nofollow noreferrer>无记忆。

Note that time between arrival also matches time until first arrival, because exponential distribution is memoryless.

这篇关于模拟泊松等待时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆