STAT 440: Homework 3 Due: 2/2
All work must be done using RMarkdown. Turn in the code as well as the output. Clearly denote the
results of each question! If the grader has a hard time nding your answer, I will instruct them to not give
you credit!
1. In this problem you may use R to simulate draws from the standard normal distribution only.
(a) Obtain 1000 samples from the chi-squared distribution with 1 degree of freedom by rst sampling
1000 samples Zi from a standard normal distribution (you can use built in R functions), and then
applying the appropriate transformation. Plot a histogram of the results. Overlay a curve onto
the histogram denoting the true density.
(b) Repeat (a), but produce t-distributed random variables with 5 degrees of freedom. Do this by
only generating standard normals (and then transforming in the appropriate way).
(c) Use Monte Carlo estimation to estimate the variance and fourth moment of Q 25, a random
variable with chi-squared distribution with 5 degrees of freedom. Use 10,000 Monte Carlo sam-
ples in your estimation. Again, carry this out by only simulating standard normals and then
transforming them in the appropriate way.
2. Empirical Veri cation of the Weak Law of Large Numbers. Use simulation to verify the
WLLN, which states that if X1;X2;:::;Xn are iid with mean , then for any xed positive number
> 0
limn!1P j X(n) j> = 0
Let Xi N(3;1) be iid random Normal variables, and estimate
n = P j X(n) j>:01
for n = 10;100;1000;10000. Use m = 1000 realizations of X(n) at each value of n to obtain a Monte
Carlo estimate of the probability n.
STAT 440: Homework 3 Due: 2/2
3. Tail Moments of the Standard Normal Distribution. Your goal is to estimate the following
conditional moment of the standard normal distribution: Z N(0;1)
= E[ZjZ > ]:
(a) Write an R function that takes inputs n (sample size) and > 0 and estimates using an
accept/reject approach. For this part, draw proposals from a standard normal.
(b) De ne a random variable Y to be exponentially-distributed with rate and with the constraint
that Y > . That is:
fY (y) =
(
C e y y>
0 y
where C is a normalizing constant. Find C in terms of and .
(c) Write an R function that takes inputs n (sample size), , and and will produce a sample from
fY , given values for and . Draw 10000 samples with = 1 and = 4:5 and plot a histogram of
the samples together with a corresponding density curve. There are many possible approaches to
choose from here, including the inverse-CDF method, rejection-sampling approaches, and using
the memoryless property of the exponential distribution to facilitate sampling.
(d) The pdf of Z, with the constraint that Z > , is:
fZ(z) =
(
C2 e z2=2 z>
0 z
where C2 is a normalizing constant. We could work out C2 in terms of the CDF of a standard
normal distribution, but lets assume that this isn’t possible, as could be the case with a less
common distribution. To use a rejection sampling algorithm, we need to nd K such that
sup h(x)f
Y (x)
K for all x
where h(x) = e x2=2 (the kernel of the standard normal distribution Z). For = 4:5, nd a K and
a that satisfy this requirement. There are many possibilities, but to make this algorithm e cient
you should nd a that lets K be as small as possible while still satisfying the requirements for
rejection sampling. Hint: plotting or nding derivatives of h(x)=fY (x) for various values of may
be useful.
(e) Now use rejection sampling with Y for a proposal distribution using the and K from part (e)
to draw 10000 samples from Z and use those samples to estimate 4:5 = E[ZjZ > 4:5]. Report
your estimate, and then use the functions dnorm and pnorm to calculate the sequred error of your
estimate (i.e. use dnorm and pnorm to nd the true value of 4:5, then report (^ 4:5 4:5)2).