Is random.expovariate equivalent to a Poisson Process

穿精又带淫゛_ 提交于 2019-12-07 06:49:25

问题


I read somewhere that the python library function random.expovariate produces intervals equivalent to Poisson Process events.
Is that really the case or should I impose some other function on the results?


回答1:


On a strict reading of your question, yes, that is what random.expovariate does.

expovariate gives you random floating point numbers, exponentialy distributed. In a Poission process the size of the interval between consecutive events is exponential.

However, there are two other ways I could imagine modelling poisson processes

  1. Just generate random numbers, uniformly distributed and sort them.
  2. Generate integers which have a Poisson distribution (i.e. they are distributed like the number of events within a fixed interval in a Poisson process). Use numpy.random.poisson to do this.

Of course all three things are quite different. The right choice depends on your application.




回答2:


https://stackoverflow.com/a/10250877/1587329 gives a nice explanation of why this works (not only in python), and some code. In short

simulate the first 10 events in a poisson process with an averate rate of 15 arrivals per second like this:

import random
for i in range(1,10):
   print random.expovariate(15)


来源:https://stackoverflow.com/questions/8592048/is-random-expovariate-equivalent-to-a-poisson-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!