Exponential Distribution

This is a discussion on Exponential Distribution within the C Programming forums, part of the General Programming Boards category; I am trying to generate numbers for a mean interarrival time of 7 seconds. My code is as follows: randomNumber ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    1

    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
    Posts
    14,826
    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:
    Code:
    r = 0.0000123;
    a = -7 * log( 1 - r );
    a *= 1000000;
    print out a
    What do you think a should be?


    Quzah.
    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 Cprogramming.com
    Replies: 50
    Last Post: 01-19-2003, 08:26 AM
  3. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 11:39 AM
  4. exponential operator
    By mikebrewsj in forum C++ Programming
    Replies: 2
    Last Post: 01-16-2002, 07:05 AM
  5. Replies: 5
    Last Post: 10-12-2001, 03:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21