hw4
hw4
Homework 4
This week’s exercises will use R. Please read the R tutorials posted on the web site for information
about R commands and syntax that will be helpful for solving the homework. Turn in a copy of
the exact commands you used and the resulting R output, in addition to any calculations you did by
hand, and any graphs you generated.
(a) Generate 1000 draws from a Poisson distribution with parameter λ = 1. Construct
a histogram of the draws, using the hist function. (Hint: when using hist, set
breaks=50 so that the histogram clearly separates the support points.) Calculate the
sample mean and variance of the 1000 draws, and compare these to the theoretical val-
ues. Also calculate the relative frequency of X = 2 in your sample of 1000 draws, and
compare this to the theoretical value.
(b) Repeat part (a), but with λ = 4. Using the histograms, compare this distribution to the
distribution in part (a).
(a) Generate 1000 draws from the Uniform[0, 1] distribution. Construct a histogram of the
draws, using the hist function, and compare the sample mean and variance of the
draws to the theoretical values. Calculate the fraction of draws greater than .75 in your
sample, and compare this to the theoretical value.
(b) Using the 1000 draws from part (a), but without generating any additional random
draws, create 1000 draws from the Uniform [−1, 2] distribution. (Explain why your
procedure correctly produces draws from the Uniform [−1, 2] distribution.) Again, cal-
culate the sample mean and variance and compare these to the theoretical values. Cal-
culate the fraction of draws greater than .75 in your sample, and compare this to the
theoretical value.