OPERATIONS RESEARCH  SIMULATION
Math 286/366
Spring, 2007
Answers
Assignments
Basic Programs
Challenge Problems
Class Notes
Extra Credit Projects
Final Spring 2002
Hints
Sample Exam 1
Sample Final
Final Spring
2005
Formula Sheet
Visual
Basic (not working at present)
Time:
MWF 9:00  9:50, MSB 315
Instructor: Professor C. Vinsonhaler
Office:
MSB 316
Phone:
4863944
Email:
vinsonhaler@math.uconn.edu
Web Page: http://www.math.uconn.edu/~vinsonhaler/math286s06/
Office Hours: MW 1010:45, Tues
910, and by appointment
Text:
Simulation, Fourth Edition, by Sheldon M. Ross

Topics: Visual Basic, Review of Probability; Random Numbers; Generating Discrete Random Variables; Generating Continuous Random Variables; The Discrete Event Simulation Approach  queueing systems, inventory, stock options, aggregate claims; Statistical Analysis of Simulated Data; Statistical Validation Techniques.
Homework & Projects: Homework will be assigned and collected about once a week. I will also give out longerterm projects, some of which will be completed by groups of 34 students. Homework and projects count 40% of your grade. You are encouraged to work together on homework. However, unless a problem is designated a group problem, you must turn in your own version of the solution. Answers must be explained in full sentences, with correct punctuation, spelling and format. Late homework will not be accepted unless prior arrangements have been made.
Exams: There will be one exam and a final. Dates will be announced in
class. The exam counts 20% and the final 40%. You may use a calculator and one
official page of notes during exams.
Midterm: March 21
Final: May 1, 3:305:30, PNB 131 Review Session: April 29, 56:30, MSB 315
Random Number Sequence: 0.305, 0.431, 0.819, 0.386, 0.091, 0.904, 0.938, 0.973, 0.317, 0.549
Nonbinding Syllabus
Week 
Topics 
1 
VBA, Chpt 1, 2.1  2.6 
2 
VBA, 2.7  2.9 
3 
VAB, 3.1  3.2 
4 
4.1  4.5 
5 
5.1  5.2, Project 1 
6 
Review, Exam 
7 
5.35.5 
8 
6.16.4, 6.6, 6.8, 6.9 
9 
7.1 7.3 
10 
9.1, Project 2 
11 
9.2  9.4 
12 
8.1, 8.2, 8.8 
13 
Actuarial Exam problems 
14 
Review 
Current
1. (due 1/22) VB
program for rolling one die
2. (due
1/26) p. 35 : 212
3. (due 1/29) VB program to flip a coin until two heads in
a row appear
4. (due 2/2) p. 35 : 14,15,23,25 and p. 47 –
2,5,6,8
5. (due
2/9) p. 62 – 1,3,4,7
6. (due 2/19) p. 64 – 14, 15, 16
7. (due 2/23) p. 87 – 1,2,3,17
8. (due 3/16) p. 88 – 8ac, 18, 24, 26
9. (due 3/25) worksheet on single server queue
10. (due 4/6)
worksheets on 2server queue, stock options
11. (due 4/16) multiple choice on bootstrap
12. (due 4/23) p. 241
– 2a,4 and Project 2
worksheet NO CLASS 4/20
13. (due 4/25) Project 2
Math 286/366 Exam 1
Spring, 2001
Explain answers or you are liable to lose credit. Problems 1,3,4,5 count
15 points, 2 and 6 count 20 points.
1. Use the 3 random numbers U = 0.5, 0.2, 0.7 to estimate the integral from 0 to 2 of (4x^2 + 2)^1/2 dx.
2. A bank with a single
cashier opens at 9:00 a.m. and admits no new customers after 11:00 a.m. They
do, however, finish serving any customers that are already in the bank by
11:00. You are asked to run a simulation to estimate the average amount of time
that a customer spends in the bank. After studying the bank you decide to model
by assuming that customers arrive according to a Poisson process with an
average of 3 arrivals per hour. You assume the service time has a Gamma(2,5) distribution. You use the following table generated
by random numbers to run the simulation. What average time estimate do you give
the bank?
(1/3)ln(U1)
.41 .24 .83
.51 .11 .89
.65 .09 .38
(1/5)ln(U2) .13
.20 .08 .32
.41 .04 .15
.05 .86
3. What are your results if you use the polar method to
generate samples using the following two pairs of random numbers: (U1,V1) = (0.12,0.05); (U2,V2) = (0.62,0.84)?
4. A random variable X has cdf
given by F(x) = .4G(x) + .6H(x), where G(x) is the cdf
for a random variable that is uniform on the interval (2,5) and H(x) is the cdf for a Binomial(2, 1/3) random variable. Use the pair of
random numbers (U1,U2) = (0.51,0.45) to obtain a
sample of X using the Composition Method.
5. The rejection method is to be used to simulate the
distribution having pdf f(x) = 2xexp(x^2)
(x > 0) using g(x) = exp(x) (x > 0). Determine the smallest expected
number of iterations to obtain a sample.
6. You want to simulate customers arriving at a Donut Shop
with a Nonhomogeneous Poisson Process that has an
intensity function lambda(t) = 2t – t^2 for 0
< t < 2 hrs. You use the most efficient value for your constant
lambda and the following table of random numbers.
ln(U1)
.41 .09 .72
.53 .11 .89
.65 .09 .38
U2 .13
.80 .55 .62
.41 .04 .15
.05 .86
Answers: 1. 4.81 2.
.3675 3. reject, (.38, 1.078) 4. X =
1 5. 2 iterations 6.
2 customers
Projects :
1. A stack of index cards is numbered 1100, turned face down and
shuffled. Then the cards are turned over one at a time. If the card numbered n
is the nth card turned over, then a "hit" occurs. Perform a
simulation to estimate the expected number of hits. Calculate the exact
expected number of hits.
2. Two dice are rolled until all 11 possible sums occur. Perform a
simulation to estimate the expected number of rolls.
3. A policy covers physical damage incurred by the trucks in a
company’s fleet. The number of losses in a year has a Poisson
distribution with m = 5. The amount of a single loss has a gamma distribution
with a = .5 and b = 1/2500 (with mean 1250). The insurance contract pays a
maximum annual benefit of $20,000. Develop a simulation to estimate the
probability that the maximum benefit will be paid. Perform enough simulations
so that there is a 90% probability that the relative error in your answer is
less than 10%. Note that if a random variable X is Gamma(0.5,b),
then X = Z^2/2b, where Z has a standard normal distribution.
4. A medical insurance policy covers a family of four. The number of
claims filed by the family during the year has a Poisson distribution with mean
10. On individual claims, the family pays a deductible amount $5 and pays
a total of no more than $50 during the year. The amount of an individual claim
is uniformly distributed over [0,50). Develop a
simulation to determine the expected present value of the insurer’s claim
payments in one year if the interest rate is 6%. Perform enough simulations so
that there is a 90% probability that the relative error in your answer is less
than 10%.
5. Two people alternate rolling two dice.
The first one to roll all 11 possible sums wins $100. Write a simulation to
determine how the pot should be split if the game is interrupted.
Projects will be graded on accuracy, creativity and presentation.
Extra Credit Problems :
Miscellaneous Exercises.
Exercise 1. Customers arrive at a single server queueing system according to a Poisson process with mean 5 per hour. The service times are independent and have a Gamma(3,10) distribution. Simulate this system for one hour (T = 1) using the following table. Use random numbers in order. What is the average time spent in the system?
(1/5)ln(U1) 
.02 
.14 
.30 
.18 
.76 
.01 
.10 
.10 
.27 






(1/10)ln(U2) 
.01 
.21 
.05 
.01 
.02 
.13 
.04 
.28 
.32 
.19 
.18 
.06 
.15 
.13 
.24 
Exercise 2.
Simulate two servers in series for two minutes. Arrivals are Poisson(2).
1. First Server: service time has pdf f1(t) = 1  abs(t1) for 0 < t < 2 (use
rejection method)
2. Second Server: service time has pdf
f2(t) = .7g(t) + .3h(t), where g(t) is the pdf for the Uniform(0,1) distribution and h(t) is the pdf for the Exponential(1/2) distribution. (use composition method)
Use the following table as needed (in order)
ln(U1)
.29 2.59 .61
.41 .51 .56
1.91 .27 .03
1.07 .04
U2 .72
.79 .63 .63
.17 .43 .62
.67 .39 .63
.37 .16 .18
.04 .50 .41
.11 .91 .704
What is the average time spent in the system?
Exercise 3.
Simulate two servers in parallel for three iterations. Arrivals are Poisson(2).
1. First Server: service time has pdf f1(t) = 1  abs(t1) for 0 < t < 2 (use
inverse transform method)
2. Second Server: service time has pdf
f2(t) = .7g(t) + .3h(t), where g(t) is the pdf for the Uniform(0,1) distribution and h(t) is the pdf for the Exponential(1/2) distribution. (use composition method) .
Use the following table as needed (in order)
ln(U1)
.65 .11 1.14
1.03 .12 1.11
.83 5.75 .14
3.26 .04
U2 .50 .41
.11 .91
.70 .58 .99
.55 .58 .01
.81
What is the average time spent in the system?
Exercise 4 .
The following experimental values of a random variable are obtained: 2.5, 3,
11/3, 13/3, 5.5. To approximate the approximation to the Mean Square Error
given by the Bootstrap Technique, three simulations are to be conducted and the
average of the three used as an approximation to MSE(Fe). Three sets of dice
rolls are used to generate the simulations:
1 
2 
2 
4 
5 
1 
2 
2 
3 
4 
1 
2 
4 
4 
4 
Determine the average of the three simulations.
Exercise 5. Claims arrive at an insurance company according to a nonhomogeneous Poisson process with intensity function lambda(t) that linearly increases from 0 to 6 over the interval [0,1/2] and then decreases linearly back to 0 at t = 1 (year). The amounts of the claims are independent and uniform on the interval [10,20]. The time between the arrival of a claim and payment of the claim is 2 weeks if the claim is less than 15 and 4 weeks otherwise. The insurance company pays a maximum of 50 for the claims that arrive in any one year. If the interest rate is 8% (discount factor 1/1.08), use the random samples in the table below to generate the present value of payments on claims incurred in a single year. You should first use the thinning method for generating the nonhomogeneous Poisson claim arrivals. Use random numbers in order.
(1/6)ln(U1) 
.06 
.29 
.09 
.11 
.23 
.01 
.10 
.10 
.27 




U2 
.77 
.38 
.59 
.12 
.33 
.34 
.28 
.38 
.62 
.60 
.40 
.29 
.28 
Unit Review Questions: EDDDBDABE
Problem Set 1: BCBECAA
Problem Set 2: DECD
AC
Final Topics
1. Linear Congruential Random Number
Generators and Inversion Method
2. Rejection Method
3. Composition Method *
4. Stopping Criteria (Chebyshev,
5. Recursion Formulas *
6. Bootstrap *
7. Goodness of Fit *
8. TwoSample Test (exact pvalue, Normal approximation
9. Multisample test
10. Projects *
Final
Math 286/366
Spring, 2001
Relevant entries
from the standard normal table (90%,95%,97.5%) = (1.28, 1.645, 1.96).
For ALL simulations required by this exam, you are to use the following random
samples, in order. The symbols U1 and U2 denote random numbers.
ln(U1) .64
.28 .42 .30 1.53
.96
U2 .50
.19 .26 .61
.87 .22
1. You want to simulate, in the most efficient way, arrivals
from 1:00 pm to 2:00 pm from a nonhomogeneous Poisson process with l(t) = 2t,
0<t<1. Under the completed simulation (using thinning), when does the
second arrival occur? Answer: [1:40]
2. After 39 simulations of a distribution, you obtain (sample mean,
sample variance ) = (32, 25).
If the 40th simulation produces a value of 33, what is the length of a 90%
confidence interval for the mean, based on your 40 simulations? [2.57]
3. You obtain the following sample from an unknown
distribution: 20,21,24,25,26,28. To generate two bootstrap samples you
roll two sequences with a die: Sequence 1: 1,1,3,3,4,6; Sequence II:
1,2,2,3,5,5. Use these to estimate the mean square error involved in estimating
the mean of the unknown distribution with the sample mean. [.625]
4. You wish to test that two samples are from the same
distribution using the rank sum test. Sample I: 1.5, 2.7, 5.7; Sample II:
0.3, 1.7, 4.7. What is the (exact) pvalue you obtain? [7/10]
5. You wish to test whether or not a sample 0.48, 0.76, 0.87,
0.96 comes from the distribution with probability density function f(x) = 2x, 0
< x < 1. What value of
D does the KolmogorovSmirnoff test produce?
[.33]
6. An insurer experiences claims that come in according to a
Poisson process with an expectation of 3 claims per year. Claims are paid
immediately. The amount of a claim has a uniform distribution on the interval
(0,2) and the interest rate is 10%. Produce one simulation of the present value
of claims during the next year. [3.01]
Challenge Problems:
1. Hugh owes Leah 62 cents, but only has a (fair) dollar coin. Devise a
game consisting of a sequence of coin flips so that Leah wins the dollar coin exactly
62% of the time.
2. Calculate the expected number of rolls of a die required to obtain all
6 possible outcomes.
Corrections to Simulation TakeHome Exam.
Problem Set 1.
5. Change the 8.8 in the first bootstrap sample to 8.6 and
change answer (C) to 0.034 (the correct answer).
Problem Set 2.
2. The correct answer is (E)
3. Calculate Q/P instead of P/Q
4. Multiply all answers by 0.1
Note: In using the KruskalWallis test, the pvalue
is NOT 2 times a Min, as stated in the text by Ross. The pvalue is just the
probability R is larger than the value obtained from the sample.
Problem Set 3.
14. An answer lower than 31 is also acceptable. In view of
this, how might you justify an answer of 31?