$24
For this lab we will run some simulations using the statistical software program R. Your solutions should contain clearly identified numerical answers and well labeled tables/figures, where appropriate. Make sure to include clear and concise interpretations (that is, clear, full sentences) of any values, figures, and responses to queries posed. Place all code in an appendix, at the end of your solutions document.
1. Evaluating a random number generator
a) Generate 10,000 variates using the random number generator, which is the original number generator used by MATLAB
Xn+1 = 16,807Xn mod(231 – 1)
b) Draw a histogram of these variates
c) Draw the empirical cumulative distribution function of these numbers against the cumulative distribution function
d) Perform a Kolmogorov-Smirnov test to validate this random number generator. Do the pseudorandom numbers appear to be uniformly distributed according to the test? Base your conclusions from the test at =0.05 level.
2. The manufacturer of SLURM soda has printed one of the five letters, S, L, U, R, and M, on the bottom of each bottle cap. The company offers a prize to anyone who collects all five bottle caps that spell SLURM. Modify the nuka.R code to simulate the appearances of the letters on the bottle caps assuming any letter is equally likely to occur. Let 1 = S, L = 2, U = 3, R = 4, 5 = M.
a) Calculate the true mean and variance of the distribution of the letters
b) Use your modified code and run this experiment 1,000 times. Present the distribution of the empirical pmf and empirical cdf of your bottle caps as a table:
c) Present a histogram of your variates
d) Present a plot of the empirical cdf versues the true cdf
e) Find the mean and variance of your distributions and compare those values with the true mean and variance