实时生成(泊松?)随机变量
我有一个实时运行的程序,具有可变帧速率,例如可以是 15 fps,可以是 60 fps。我希望平均每 5 秒发生一次事件。每一帧,我想调用一个函数,该函数将自上一帧以来的时间作为输入,并在调用它的情况下平均每 5 秒的运行时间返回 True 一次。我认为与泊松分布有关..我该怎么做?
I have a program running in real-time, with variable framerate, e.g. can be 15 fps, can be 60fps. I want an event to happen, on average, once every 5 seconds. Each frame, I want to call a function which takes the time since last frame as input, and returns True on average once every 5 seconds of elapsed-time given it's called. I figure something to do with Poisson distribution.. how would I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这实际上取决于您想要使用什么分布,您指定的只是平均值。正如您所说,我希望泊松分布能够很好地满足您的需求,但您还在标题中添加了“均匀随机变量”,这是一种不同的分布,无论如何,让我们选择前者。
因此,如果泊松分布是您想要的,您可以使用累积密度函数非常轻松地生成样本。只需按照此处的伪代码操作即可:生成泊松 RV,其中 5 秒是您的值拉姆达。我们将此函数称为 Poisson_RN()。
此时的算法非常简单。
It really depends what distribution you want to use, all you specified was the mean. I would, like you said, expect that a Poisson distribution would suit your needs nicely but you also put "uniform random variable" in the title which is a different distribution, anyway let's just go with the former.
So if a Poisson distribution is what you want, you can generate samples pretty easily using the cumulative density function. Just follow the pseudocode here: Generating Poisson RVs, with 5 seconds being your value for lambda. Let's call this function Poisson_RN().
The algorithm at this point is pretty simple.
通过独立试验以固定比例生成真/假结果的随机变量称为几何随机变量 。在任何时间范围内,以 1/(5*fps) 的概率生成 true,从长远来看,平均每 5 秒生成一个 true。
A random variable which generates true/false outcomes in fixed proportions with independent trials is called a Geometric random variable. In any time frame, generate true with probability 1/(5*fps) and in the long run you will get an average of one true per 5 seconds.