Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

6 Solved Questions on Simulation - Assignment 2 | ISYE 6644, Assignments of Systems Engineering

Material Type: Assignment; Class: Simulation; Subject: Industrial & Systems Engr; University: Georgia Institute of Technology-Main Campus; Term: Summer 2009;

Typology: Assignments

Pre 2010

Uploaded on 09/17/2009

koofers-user-y8q
koofers-user-y8q 🇺🇸

5

(1)

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
ISyE 6644 Summer 2009
Homework #2 Solutions
1. Use the basic Monte Carlo technique from class to integrate
I=Z1
1
1
2πexp{−x2/2}dx.
(a) Use n= 100 Unif(0,1) random variates to produce your answer. Repeat this
50 times and make a histogram of the results.
(b) Using the above 50 runs, estimate the variance of ˆ
I100.
(c) Can you think of any way to calculate an “exact” answer?
By the way, if you need a uniform generator, here’s an easy FORTRAN function
that a lot of people use: (Of course, if you don’t want to do any programming, you
can use Excel; or you can just pick a whole bunch of uniforms out of your head
but this might get a little tedious!!)
FUNCTION UNIF(IX)
K1 = IX/127773 (Note: this division truncates, e.g., 5/3 = 1.)
IX = 16807*(IX - K1*127773) - K1*2836 (seed is updated for next use)
IF(IX.LT.0)IX = IX + 2147483647
UNIF = IX * 4.656612875E-10
RETURN
END
Solution. (a)
ˆ
In=ba
n
n
X
i=1
f(a+ (ba)Ui)
=2
100
100
X
i=1
f(1 + 2Ui)
(since a=1, b= 1, and n= 100)
=1
50
100
X
i=1
1
2πe(1+2Ui)2.
pf3

Partial preview of the text

Download 6 Solved Questions on Simulation - Assignment 2 | ISYE 6644 and more Assignments Systems Engineering in PDF only on Docsity!

ISyE 6644 — Summer 2009

Homework #2 Solutions

  1. Use the basic Monte Carlo technique from class to integrate

I =

∫ (^1)

− 1

2 π

exp{−x^2 / 2 } dx.

(a) Use n = 100 Unif(0,1) random variates to produce your answer. Repeat this 50 times and make a histogram of the results. (b) Using the above 50 runs, estimate the variance of Iˆ 100. (c) Can you think of any way to calculate an “exact” answer?

By the way, if you need a uniform generator, here’s an easy FORTRAN function that a lot of people use: (Of course, if you don’t want to do any programming, you can use Excel; or you can just pick a whole bunch of uniforms out of your head — but this might get a little tedious!!)

FUNCTION UNIF(IX)

K1 = IX/127773 (Note: this division truncates, e.g., 5/3 = 1.) IX = 16807(IX - K1127773) - K1*2836 (seed is updated for next use) IF(IX.LT.0)IX = IX + 2147483647 UNIF = IX * 4.656612875E- RETURN END

Solution. (a)

Iˆn = b^ −^ a n

∑^ n

i=

f (a + (b − a)Ui)

∑^100

i=

f (−1 + 2Ui)

(since a = −1, b = 1, and n = 100)

=

∑^100

i=

2 π

e−(−1+2Ui)

2 .

Now you do the rest (50 times). 2

(b) Just take the sample variance of your 50 replications from (a). 2

(c) The actual answer is

I =

∫ (^1)

− 1

2 π

exp{−x^2 / 2 } dx

= 2Φ(1) − 1 (where Φ(·) is the standard normal c.d.f.) = 2(0.8413) = 0. 6826. 2

  1. Let’s make some pi. Consider a unit square with a circle of radius 1/2 inscribed in it. Toss a dart randomly at the square. The probability that the dart will hit inside the circle is the ratio of the area of the circle to that of the square, i.e., π/4. If you toss n darts at the square, the proportion ˆpn that hit the circle converges to π/4. Therefore, the random variable 4ˆpn is an estimator for π. Implement this Monte Carlo scheme in your favorite language to estimate π. Plot your estimates for sample sizes of n = 2, 4 , 8 ,... , 2048. (Use a logarithmic scale for the x-axis.) Does your answer seem to be converging to 3.14159? (I hope so.)

Hints: You may need to recall that the relevant circle is described by (x − 1 /2)^2 + (y − 1 /2)^2 ≤ 1 /4. Generate the ith dart by using [U 1 i, U 2 i], where the U ’s are i.i.d. Unif(0,1) random variables.

Solution. Lots of ways to do this problem. If you follow the hint, simply deter- mine the proportion of time that your darts fall inside the circle, say ˆpn. Then, as discussed in class, the estimator for π is ˆπn = 4ˆpn. You should be getting slow but pretty steady convergence to π as the sample size gets larger. 2

  1. With the previous question in mind, implement a Monte Carlo scheme to estimate the volume in a sphere with radius 1/2.

Solution. Your answer should converge to 43 πr^3 = π/6. 2