最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

模拟泊松等待时间

SEO心得admin150浏览0评论
本文介绍了模拟泊松等待时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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]).

关于生成指数变量。

请注意,到达之间的时间也与首次到达之前的时间相匹配,因为指数分布为无记忆。

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

发布评论

评论列表(0)

  1. 暂无评论