0% found this document useful (0 votes)
130 views3 pages

12 Sim Hw2 Sol

The document provides solutions to an assignment involving simulations. It includes: 1) Calculations of the expected commute time and its variance using conditional probability. 2) Explanations that correlation is positive if an event is more likely to occur given another event. 3) Computation of a confidence interval for sample mean from a sample and determining the necessary sample size to achieve a given precision.

Uploaded by

Johnny Timoney
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
130 views3 pages

12 Sim Hw2 Sol

The document provides solutions to an assignment involving simulations. It includes: 1) Calculations of the expected commute time and its variance using conditional probability. 2) Explanations that correlation is positive if an event is more likely to occur given another event. 3) Computation of a confidence interval for sample mean from a sample and determining the necessary sample size to achieve a given precision.

Uploaded by

Johnny Timoney
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

IEOR 4404 Assignment #2 Solutions

Simulation September 24, 2012


Prof. Mariana Olvera-Cravioto Page 1 of 3
Assignment #2 Solutions
1. Let S be your total commute time, N be the number of red trac lights you encounter
on your way to work, and X
i
be the delay on the i
th
red light. Then, S = 15 +
N

i=1
X
i
.
Note that N is a Binomial r.v. with parameters (7, 0.2), and E[X
1
] = (0.5 + 2)/2 = 1.25,
var(X
1
) = (2 0.5)
2
/12 = 0.1875. Using the conditional expectation and variance formulas:
E[S] = 15 +E[N]E[X
1
] = 15 + (1.4)(1.25) = 16.75
var(S) = var(E[S|N]) +E[var(S|N)] = var(NE[X
1
]) +E[Nvar(X
1
)]
= (E[X
1
])
2
var(N) + var(X
1
)E[N] = (1.25)
2
7(0.2)(0.8) + (0.1875)(1.4) = 2.0125
Another option is to dene Y
i
to be your total delay on the i
th
light (it might be zero if you
encounter a green light). Then, S = 15 +

7
i=1
Y
i
, and
E[Y
1
] = E[Y
1
|green light](0.8) +E[Y
1
|red light](0.2) = 0(0.8) + (1.25)(0.2) = 0.25
E[Y
2
1
] = E[Y
2
1
|green light](0.8) +E[Y
2
1
|red light](0.2) = 0(0.8) + (1.75)(0.2) = 0.35
var(Y
1
) = 0.35 (0.25)
2
= 0.2875
so
E[S] = 15 + 7(0.25) = 16.75 var(S) = 7(0.2875) = 2.0125
2. (a) Note that E[X] = P(A), E[Y ] = P(B) and
E[XY ] = P(A B) = P(A|B)P(B)
Therefore, cov(X, Y ) = E[XY ] E[X]E[Y ] = P(A|B)P(B) P(A)P(B) = [P(A|B)
P(A)]P(B). Also, var(X) = P(A)(1 P(A)) and var(Y ) = P(B)(1 P(B), so
(X, Y ) =
[P(A|B) P(A)]P(B)
_
P(A)(1 P(A))P(B)(1 P(B))
(b) It is clear from the above expression that the only way in which (X, Y ) > 0 is if
P(A|B) > P(A). This makes sense because if A is positively correlated with B, then if
conditioning on the event that B happens, A is more likely to happen.
2 IEOR 4404, Assignment #2 Solutions
3. (a) Applying the formulas

X(10) =
1
10

10
i=1
x
i
and S
2
(10) =
1
101

10
i=1
(x
i
x)
2
, we get
that:

X(10) 6.38 and S
2
(10) 2.1618. Then, recall the formula of condence interval
_

X(n) t
n1,1/2
_
S
2
(n)
n
,

X(n) +t
n1,1/2
_
S
2
(n)
n
_
where n = 10, t
9,0.975
= 2.262 yields the 95 percent condence interval:
(5.3283, 7.4317)
(b) The 90% condence interval for is (5.5277,7.2323) and the 99% condence interval is
(4.8689,7.8910). Since fall inside all condence intervals, we would not reject the null
hypothesis in any case.
(c) In this case, we want t
n1,1/2
_
S
2
(n)
n
0.25. We set the condence level to 95%. In
order to get a conservative estimate for n, we use t
9,0.975
, which is larger than t
n1,0.975
for bigger values of n. We also use S
2
(10) = 2.1618 for S
2
(n), which is the only estimate
we have for the variance. Consequently, we get that n
(2.262
2
)(2.1618)
0.25
2
= 176.98. Hence,
we need at least 177 samples to guarantee a 95% condence interval with width less than
or equal to 0.5.
4. According to the simulations we can guess that E[N] = e 2.7183. We provide with a 95%
Condence Interval of Monte Carlo approximation of E[N].
k = 10
2
k = 10
3
k = 10
4
E[N] [2.5949, 2.9251] [2.6318, 2.7362] [2.7171, 2.7517]
5. Below is the code for this problem.
U = zeros(14,1);
U(1,1) = ceil(rand*13);
for i=2:14
U(i,1) = mod(U(i-1,1) + 12,13);
end
plot(U(1:13,1),U(2:14,1))
And here is a sample output:
IEOR 4404, Assignment #2 Solutions 3
6. (a) Using the substitution u = (x (2))/(2 (2)) = (x + 2)/4 or x = 4u 2,then
_
2
2
e
x+x
2
dx
=
_
1
0
4e
16u
2
12u+2
du
Applying simulation, where h(u) = 4e
16u
2
12u+2
,
_
1
0
4e
16u
2
12u+2
du

N
i=1
h(U
i
)
N
93.1
where N = 10
6
.
(b) Integrating gives
_

0
x(1 +x
2
)
2
dx =
1
2
_

1
1
u
2
du =
1
2u

1
=
1
2
Using the substitution u = (1 +x
2
)
1/2
, du = x(1 +x
2
)
3/2
dx we get
_

0
x(1 +x
2
)
2
dx =
_
0
1
udu =
_
1
0
udu
Using simulation with h(u) = u,
_

0
x(1 +x
2
)
2
dx
1
n
n

i=1
U
i
0.5001
where the U
i
are iid uniform (0,1) random variables, n = 10
6
.
(c)
_
1
0
_
1
0
g(x, y)dxdy =
_
1
0
_
1
0
e
(x+y)
2
dxdy

N
i
g(X
i
, Y
i
)
N
where X
i
and Y
i
are independent standard uniform distributed random variables.
By using simulation,
_
1
0
_
1
0
e
(x+y)
2
dxdy 4.9017, when N = 10
7
.

You might also like