Say I am not allowed to use built-in PoissonDistribution, which means I should generate 100 random numbers first, and then with these 100 random numbers to generate 100 random variates from Poisson with rate 2, how to use inverse transform method?

  • 1
    $\begingroup$ Read this: en.wikipedia.org/wiki/… . You say how to use inverse transform method? but this requires the PoissonDistribution's CDF. $\endgroup$
    – flinty
    Oct 7, 2020 at 13:13
  • 1
    $\begingroup$ ^ directly applying inverse-transform-sampling will be awkward because you'll have to find an inverse for GammaRegularized[1 + Floor[x], λ]. However, see the method algorithm poisson random number (Junhao, based on Knuth) at the bottom of that article. $\endgroup$
    – flinty
    Oct 7, 2020 at 13:26

1 Answer 1


Directly translating the Wikipedia article linked in the comments:

poissonRandomNumber[λ_] := 
 Module[{L = Exp[-λ], k = 0, p = 1, u},
  While[p > L,
   p = p*RandomReal[];
  Return[k - 1]]

Histogram[Table[poissonRandomNumber[10], 20000]]

poisson histogram


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.