Thread: Exponential Distribution

  1. #1
    Registered User
    Join Date
    Nov 2009

    Exponential Distribution

    I am trying to generate numbers for a mean interarrival time of 7 seconds. My code is as follows:

    randomNumber = (double) rand_r(&randseed)/RAND_MAX;
    arrivalTime = -MEAN_INTERARRIVALTIME * log(1 - randomNumber);
    arrivalTime = 1000000 * arrivalTime;

    MEAN_INTERARRIVALTIME is set to 7 and randseed is 100. When I run my program though, I get really large numbers. Am I doing this completely wrong, or what do I need to change? Thanks in advance.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Why don't you just post a small "working" example? A nice small piece of code showing what you expect, and describe it? Also, you could for the sake of testing, skip the whole random part, and just assign manual numbers and see if it's working as you anticipate:
    r = 0.0000123;
    a = -7 * log( 1 - r );
    a *= 1000000;
    print out a
    What do you think a should be?

    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. RTTI for distribution
    By coletek in forum C++ Programming
    Replies: 6
    Last Post: 09-13-2010, 10:05 AM
  2. Which distribution of Linux should I get?
    By joshdick in forum A Brief History of
    Replies: 50
    Last Post: 01-19-2003, 09:26 AM
  3. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  4. exponential operator
    By mikebrewsj in forum C++ Programming
    Replies: 2
    Last Post: 01-16-2002, 08:05 AM
  5. Replies: 5
    Last Post: 10-12-2001, 03:51 AM