+ Reply to Thread
Results 1 to 4 of 4

Generating Poisson Random Variables

Hybrid View

  1. #1
    Registered User
    Join Date
    07-24-2012
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    2

    Generating Poisson Random Variables

    Does anyone know how to generate Poisson random variables when the mean is above 745? Using the code below work up to a mean of 745, after that point it just loops infinitely. I think it is related to the machine epsilon of Excel but I don't know of a work around to make it operate above 745.

    Public Function pos(Mean)
    ' Generate and return a random Poisson variable
    ' with mean Mean
    Dim Value As Double
    Dim Prod As Double
    Value = Exp(-Mean)
    Prod = 1
    Do Until (Prod < Value)
    pos = pos + 1
    Prod = Prod * Rnd()
    Loop
    pos = pos - 1
    End Function


    ---------- Post added at 02:13 PM ---------- Previous post was at 11:10 AM ----------

    I'm still struggling with this...

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Generating Poisson Random Variables

    EXP(-745) is the limit for double-precision floating point.

    I wonder (don't know) if it's true that pos(n)+pos(n) has the same distribution as pos(2n). If so, that's an easy(ish) way out.

    A Poisson distribution is infinitely divisible; I think that means that the foregoing is true, but not sure.
    Last edited by shg; 07-24-2012 at 03:58 PM.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    07-24-2012
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Generating Poisson Random Variables

    Yes, the sum of two independent Poisson random variables is itself Poisson distribution. So I can just split up the lambda into multiple random variables when going above 745.

    Thanks for the help.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Generating Poisson Random Variables

    Knuth writes about another (and faster) method for large u by Ahrens and Dieter that starts with a gamma-distributed variate; it runs in O(log(u)) time instead of O(u) (the code you posted). But I don't have a routine for gamma variates ...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1