-
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.
-
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.