
I am having probability difficulties...HELP
Quote:
>How can I simulate customer arrivals, in say a restaurant, using
>a Negative Exponential Distribution (NED) in C?
I'll just give some hints, since this looks like a homework problem.
If the probability of a customer arriving in a given period is
constant, then it is fairly easy to show that the probability that a
customer will arrive after t is
P(t) = (1/T) exp (-t/T)
where T is the mean time before a customer arrives. Thus, in a
simulation, one selects a deviate from this distribution to represent
the time between a given point (say opening time or the arrival of the
previous customer) and the next customer.
To select a deviate t, make the change of variables
t = -T log (Tu)
so that
P(u) = u
Clearly, u is a uniform deviate on (0,1] -- err, I've just had a blank
on the notation, but I mean to exclude 0 and include 1. You can
generate uniform deviates using rand() and RAND_MAX in <stdlib.h>, but
be careful to generate them on (0,1] and not [0,1), and then use log()
in <math.h> to generate a value of t.