Results 1 to 10 of 10

Math Help - "Inverse" of exponential distribution?

  1. #1
    Newbie
    Joined
    Dec 2007
    Posts
    5

    "Inverse" of exponential distribution?

    I'm embarrassed that I apparently remember nothing about statistics, but I'm hoping this is a pretty simple problem:

    I'm trying to simulate the arrival of people in a queue using an exponential distribution function. To sample from the PDF, I do:

    x = -ln(u) * v

    Where u is a uniform random variable in [0, 1) and v is a scaling factor so that E[X] = v. This gives me the expected period between people. Unfortunately, what I want is to sample expected *frequency*.

    Any tips would be really useful. Or maybe I'll just go dig up my old stats books...

    Thanks!
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Talisman00 View Post
    I'm embarrassed that I apparently remember nothing about statistics, but I'm hoping this is a pretty simple problem:

    I'm trying to simulate the arrival of people in a queue using an exponential distribution function. To sample from the PDF, I do:

    x = -ln(u) * v

    Where u is a uniform random variable in [0, 1) and v is a scaling factor so that E[X] = v. This gives me the expected period between people. Unfortunately, what I want is to sample expected *frequency*.

    Any tips would be really useful. Or maybe I'll just go dig up my old stats books...

    Thanks!
    The expected frequency is 1/v

    RonL
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Dec 2007
    Posts
    5
    Quote Originally Posted by CaptainBlack View Post
    The expected frequency is 1/v

    RonL
    Sorry, I probably should have worded my question more carefully: what I want is to sample from the frequency distribution (and, more generally, to know what the formula for the frequency PDF is).

    Maybe that's trivial too -- I'll have to sleep on it though!
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Talisman00 View Post
    Sorry, I probably should have worded my question more carefully: what I want is to sample from the frequency distribution (and, more generally, to know what the formula for the frequency PDF is).

    Maybe that's trivial too -- I'll have to sleep on it though!
    What do you mean sample from the frequency distribution?

    The number of arrivals in a time interval of length T has a Poisson distribution
    with mean T/v.

    RonL
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Dec 2007
    Posts
    5
    Quote Originally Posted by CaptainBlack View Post
    What do you mean sample from the frequency distribution?

    The number of arrivals in a time interval of length T has a Poisson distribution
    with mean T/v.

    RonL
    A ha! That's enlightening. Given this relationship between the exponential distribution and the Poisson distribution, I'm surprised I didn't come across it in my online searching -- but now that you've shown me the light, I find lots of explanations.

    Trying to use the parlance: I want to generate Poisson variates(?), much in the same way I used -ln(u)*v to generate exponential variates for wait time. It looks like there's some literature on this out there, so I think I'll head off in that direction.

    Thanks again!
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Talisman00 View Post
    A ha! That's enlightening. Given this relationship between the exponential distribution and the Poisson distribution, I'm surprised I didn't come across it in my online searching -- but now that you've shown me the light, I find lots of explanations.

    Trying to use the parlance: I want to generate Poisson variates(?), much in the same way I used -ln(u)*v to generate exponential variates for wait time. It looks like there's some literature on this out there, so I think I'll head off in that direction.

    Thanks again!
    If you have access to Don Knuth's TAOCP see volume 2 semi-numerical
    algorithms for the method (it is equivalent to generating exponentials untill
    the sum of them exceeds T).

    RonL
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    Dec 2007
    Posts
    5
    Quote Originally Posted by CaptainBlack View Post
    (it is equivalent to generating exponentials untill
    the sum of them exceeds T).
    This is actually what I'm doing now, although I felt too sheepish to get this code reviewed . Looking at other code online, I guess I can save a few log calculations (one per go-round) but still have to iterate. Ick.

    If TAOCP doesn't have a much better solution, I guess I'll stick with what I have.

    Thanks!

    [edit] I should mention that this is not a performance-critical application. I just want to avoid outrageously inefficient code.
    Follow Math Help Forum on Facebook and Google+

  8. #8
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Talisman00 View Post
    This is actually what I'm doing now, although I felt too sheepish to get this code reviewed . Looking at other code online, I guess I can save a few log calculations (one per go-round) but still have to iterate. Ick.

    If TAOCP doesn't have a much better solution, I guess I'll stick with what I have.

    Thanks!

    [edit] I should mention that this is not a performance-critical application. I just want to avoid outrageously inefficient code.
    TAOCP does essentially what I described above, but Knuth has some nice
    touches which make it look as though its doing something else and can
    save a lot of transcendental function evaluations.

    RonL
    Follow Math Help Forum on Facebook and Google+

  9. #9
    Newbie
    Joined
    Dec 2007
    Posts
    5
    Quote Originally Posted by CaptainBlack View Post
    TAOCP does essentially what I described above, but Knuth has some nice
    touches which make it look as though its doing something else and can
    save a lot of transcendental function evaluations.

    RonL
    Instead of waiting 'til the sum of ln(-u) exceeds T, I guess I can wait 'til the product of u exceeds exp(-T), which saves me enough computation for my needs.

    A related question: I'm making a wild guess that my actual distribution is Poisson. Supposing I can get some nitty-gritty data, can you suggest either (1) a good way to measure "how Poisson" it is, or (2) a way to determine what "well-known" distribution fits it best (parameters and all)?

    I realize the second one is rather involved, but I'm willing to settle for a very rough approximation (that doesn't involve keeping around a large table of past stats).
    Follow Math Help Forum on Facebook and Google+

  10. #10
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Talisman00 View Post
    Instead of waiting 'til the sum of ln(-u) exceeds T, I guess I can wait 'til the product of u exceeds exp(-T), which saves me enough computation for my needs.

    A related question: I'm making a wild guess that my actual distribution is Poisson. Supposing I can get some nitty-gritty data, can you suggest either (1) a good way to measure "how Poisson" it is, or (2) a way to determine what "well-known" distribution fits it best (parameters and all)?

    I realize the second one is rather involved, but I'm willing to settle for a very rough approximation (that doesn't involve keeping around a large table of past stats).
    The first step is always to look at the data, but if I can see some data
    I think I could suggest something.

    As a default I would expect to perform a chi-squared test.

    RonL
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 3
    Last Post: October 17th 2011, 02:50 PM
  2. Replies: 1
    Last Post: September 16th 2011, 01:08 AM
  3. Replies: 2
    Last Post: June 4th 2011, 12:11 PM
  4. Replies: 2
    Last Post: April 24th 2011, 07:01 AM
  5. Replies: 1
    Last Post: October 25th 2010, 04:45 AM

Search Tags


/mathhelpforum @mathhelpforum