How do I generate discrete random events with a Poisson distribution?

前端 未结 2 1310
醉酒成梦
醉酒成梦 2021-02-15 18:12

I\'m aware of Knuth\'s algorithm for generating random Poisson distributed numbers (below in Java) but how do I translate that into calling a method, generateEvent()

2条回答
  •  心在旅途
    2021-02-15 18:24

    The Poisson random numbers you are generating, as Scott mentioned, represent the frequency of your events. Once you have the frequency, you can fit their occurrences over the interval using a second distribution, say Uniform.

    Suppose the number of events generated for an interval of N is k. Then you simply need to generate (k+1) random numbers that sum to N.

    |<----------------------- N ------------------------->|
    --r_0--(event)---r_1-..-(event_k)--r_(k+1)--

    To do so, simply generate (k+1) random numbers and divide them by their sum, divided by N. The first k of these numbers become the timestamps of your events.

提交回复
热议问题