F(x)=1-exp(-Lx) - Computer Sciencecs2.uco.edu/~trt/cs2613/L018.pdf · We find x, a random variable...

2

Click here to load reader

Transcript of F(x)=1-exp(-Lx) - Computer Sciencecs2.uco.edu/~trt/cs2613/L018.pdf · We find x, a random variable...

Page 1: F(x)=1-exp(-Lx) - Computer Sciencecs2.uco.edu/~trt/cs2613/L018.pdf · We find x, a random variable drawn from the ... (& ,char*titl ,int ,char* ); void ... L018.doc Author: trturner

Programming II Lecture 18 CMSC 2613 Intermediate Simulation

1

λ µ

Figure 1. M/M/1 queue

∞<≤−

=−

otherwisexife

xFx

,00,1

)(λ

Figure 2. Exponential Distribution Function

F(x)=1-exp(-Lx)

0

0.2

0.4

0.6

0.8

1

1.2

0 1 2 3 4 5 6

x

F(x)

Figure 3. The CDF of an exponentially distributed random variable with parameter 1=λ

u is a random variable drawn from the uniform distribution. We find x, a random variable drawn from the

exponential distribution by setting tetFu λ−−== 1)( and solving for x. teu λ−−= 1 (1)

λ)1ln( u

t−

−= (2)

t is a random variable drawn from the exponential distribution. t represents a time between events. For example, t could be the time between arrivals or the time between departures. Simulation mechanics require an elapsed time rather than the time between events. For example, instead of receiving the following sequence of inter-arrival times 1 3 2 4, the simulation requires the time of the event relative to the start of the simulation. The foregoing sequence of times is transformed to 1 4 6 10. Finally, the simulation must manage two such sequences of timed events. The first sequence lists the time of arrivals and the second marks the time of departures. Both sequences are merged and sorted by time in ascending order.

Page 2: F(x)=1-exp(-Lx) - Computer Sciencecs2.uco.edu/~trt/cs2613/L018.pdf · We find x, a random variable drawn from the ... (& ,char*titl ,int ,char* ); void ... L018.doc Author: trturner

Programming II Lecture 18 CMSC 2613 Intermediate Simulation

2

SimRunistream iPrintostream o

();void ( & );void ( & );

void (double );void (double );void ( & ,char* ,int ,char* );void ( & ,char* t ,double ,char* );

Arrival timeDeparture timePrintLine

ostream o title v unitsPrintLine

ostream o itle v units

Sim

UniformSample()

double (void)

Uniform

ExponentialSample

(double )double (void)

λ

Exponential

ExponentialElapsed

ExponentialElapsedTime

(double )double (void)

λ

Data D;ExponentialElapsed Arrival;ExponentialElapsed Departure;Queue Data Q;< >

EventOccur

Time

(double ,double );void (void); double (void);bool IsArriva(void);bool IsDeparture(void);

λ µ

Event

Figure 2. Project p05 class hierarchy