Math 350 - Homework 10 - Solutions
1. In certain situations a random variable X , whose mean is known, is simulated so as to obtain an estimate
of P cfw_X a for a given constant a. The raw simulation estimator from a single run is I , where
I=
1
if X a
0

Math 350 - Homework 6 - Solutions
1. We wish to generate a random variable X taking values in [0, 1], having probability density function
f (x) = ex /(e 1).
(a) Write a program based on the inverse transform method to generate X .
(b) Show that your progr

Math 350 - Homework 3 - Solutions
1. The bus will arrive at a time that is uniformly distributed between 8 and 8 : 30 A.M. If we arrive at 8
A.M., what is the probability that we will wait between 5 and 15 minutes?
The probability that we will have to wai

Math 350 - Homework 7 - Solutions
1. Write a program to generate the desired output for the model of Section 6.2. Use it to estimate the average
time that a customer spends in the system and the average amount of overtime put in by the server, in
the case

Math 350 - Homework 8 - Solutions
1. For any set of numbers x1 , . . . , xn , prove algebraically that
n
n
i=1
where x =
n
i=1
(xi x)2 =
i=1
x2 nx2
i
xi /n.
i=1
n
n
n
(x2 2xi x + x2 ) =
i
i=1
n
=
i=1
n
=
i=1
x2 2
x
i
xi + nx2
i=1
x2 2nx2 + x2 n
i
x2 nx2 .

Math 350 - Homework 9 - Solutions
1. Suppose we wanted to estimate , where
1
2
ex dx.
=
0
2
(a) Show that Y1 = eU (1 + e12U )/2 is an unbiased estimator of ;
2
2
(b) Show that Y1 is a better estimator than Y2 = (exp(U1 )+exp(U2 )/2, where U1 and U2 are in

MARKOV CHAIN MONTE CARLO EXAMPLES
Hastings-Metropolis for Integration Problems:
1
E [h(X)] =
h(x)p(x)dx
N
D
N
h(Xi).
i=1
H-M algorithms often sample from neighboring elements of
states X. Then the transition q (X, Y) is a distribution on the
set of neigh

MARKOV CHAIN MONTE CARLO METHODS
Gibbs Sampling: this is a type of Hastings-Metropolis algorithm.
Suppose x = (x1, x2, . . . , xn) and assume we need to compute
= E [h(X)] =
h(xi)pi,
h(x)p(x)dx or
i
for some density p(x) which is dicult to sample from.
O

MARKOV CHAIN MONTE CARLO METHODS
Background: for many simulation problems need to compute
= E [h(X)] =
h(x) (x)dx or
h(xi)i,
i
for some density (x) which is dicult to sample from.
Markov Chains: assume RVs X0, X1, X2, . . . are states of some
system at t

MACHINE REPAIR and STOCK OPTION MODELS
Machine Repair Model Simulation
Assumptions:
a) system needs n working machines;
b) machines fail independently after time X F , some F ;
c) broken machine immediately replaced and sent for repair;
d) one-person rep

STRATIFIED SAMPLING APPLICATIONS
Multdimensional Integrals: consider the 2-dimensional
1
1
=
g (x, y )dxdy
0
0
Simple stratied sampling.
If subdivision of [0, 1] [0, 1] is same for x and y , strata are
j
i
squares sij = [ i1 , k ] [ j 1 , k ], for i = 1

STRATIFIED SAMPLING
Stratied Sampling Background: suppose = E [X ].
Simple MC simulation would use X . If X simulation
depends on some discrete Y with pmf P cfw_Y = yi = pi,
i = 1, . . . , k , and X can be simulated given Y = yi,
k
k
piXi = .
piE [X |Y =

Math 350 - Homework 5 - Solutions
1. A deck of 100 cardsnumbered 1, 2, . . . , 100is shued (i.e., a random permutation is applied to the
cards in the deck) and then turned over one card at a time. Say that a hit occurs whenever card i is
the ith card to b

Math 350 - Homework 4 - Solutions
1. If x0 = 5 and
xn 3xn1 (mod 150)
nd x1 , . . . , x10 .
Note that this is equivalent to xn 3n 5(mod 150), n = 1, . . . , 10, which is the remainder in
cfw_0, 1, . . . , 149 after dividing 3n 5 by 150. These are
x1 = 15,

DISCRETE EVENT SIMULATION
Discrete Event Simulation Overview
Events: need description of possible events and distributions;
event list is maintained and updated as system changes.
Variables: time t, counters, system state and output variable.
Examples:

VERIFICATION and TESTING
Verication and Testing for Simulation Programs
Standard Program Debugging:
a) initially develop programs with good structure,
including use of functions and some comments;
b) display of intermediate results to nd bugs,
check for

ESME 273
Discrete Event Simulation
Ross Chapter 2 (part A)
Dr. William J.J. Roberts
wroberts@gwu.edu
1
Simulation Example
Consider a small pharmacy that opens at 9am and lls 32 prescriptions per day, on average. One might be interested in the
following:

ESME 273
Discrete Event Simulation
Ross Chapter 2 (part B)
Dr. William J.J. Roberts
wroberts@gwu.edu
1
In chapter 2 part A we reviewed basic probability concepts
and simulated some discrete random variables
In chapter 2 part B we will continue our proba

Random Numbers
Ross Chapter 3
1
Generating Random Numbers
The generation of random numbers represents a building
block of any simulation study
The generation of uniform U (0, 1) random numbers represents a building block for the generation of other type

Generating Discrete Random Variables
1
Generating Discrete Random Variables
From the last chapter we know how to generate continuous
uniform rvs
How would we generate discrete uniform rvs?
How would we generate discrete nonuniform random variables?
Th

Generating Continuous Random Variables
1
Generating Continuous Random Variables
Each of the techniques applied to generate discrete rvs has
its analog in the continuous case
2
Inverse transform method
A continuous rv X having cumulative distribution fun

Discrete Event Simulation & Other Applications
1
Systems simulation
Consider a system that we wish to simulate, e.g.
customers in a bank
weather prediction
economic modeling
Simulating such a system involves generating random data,
inputting this int

Statistical Analysis of Simulated Data
1
Statistical analysis basic framework
Assume a simulation study is concerned with estimating
could be, e.g., an integral estimated using Monte-Carlo;
the time that the last customer leaves a bank estimated
using

Variance Reduction Techniques
1
The raw estimator X
As we have seen, in a typical simulation to estimate , n iid
data points cfw_X1, . . . , Xn are averaged together to produce
the unbiased estimate X
X = 1/n
n
Xi.
i=1
Then X
We have seen that sometime

Math 350 - Homework 2 - Solutions
1. If X and Y have a joint probability density function given by
f (x, y ) = 2e(x+2y)
for x and y in (0, ), nd the probability P (X < Y ).
The probability density function f (x, y ) is dened on the rst (positive) quadrant

TWO-SERVER QUEUE SIMULATION
Two Servers in Series
Assumptions: nonhomogeneous (t) Poisson arrivals;
service at server 1, then by server 2 service for each customer;
service times are RVs with distribution G1 and G2;
no customers after nal arrival time T.