首页 > > 详细

讲解STAT2011调试R、R语言程序解析、讲解R程序

The University of Sydney - School of Mathematics Statistics 
STAT2011 Probability and Estimation Theory, 2020 
Computer Assignment - Due by 23.59pm on Friday 29 May. 
Computer Assignment 
Instructions: Complete this computer assignment and submit all of your code, any output 
and comment required by the questions in pdf or html format via turnitin (through canvas) 
before expiration of the time. 
1. In a gambling game, a player wins the game if he/she rolls three fair, six-sided dice, and 
gets a sum of at least 11. We will use simulation to approximate the probability. Use 
set.seed(200) for this question. 
(a) Generate 104 random rolls of three dice and store the results in a 104 × 3 matrix. 
(b) Find the sums of these 104 rolls. (Showing your code suffices, please do not print 
the results.) 
(c) What is the probability of winning based on your simulation? 
2. (a) The frequency table below summarises observed frequencies (O) of 60 counts: 
Value, k 0 1 2 3 4 
Freq 7 19 12 13 9 
Assuming that these data are i.i.d. and come from a Poisson distribution with 
unknown rate λ with probability P (X = k) = e 
−λλk 
k! for k = 0, 1, 2, 3, 4. Use R to 
answer the following questions. 
(i) Estimate λ using the method of moments. 
(ii) Estimate the variance of your estimator for λ in (i). 
(iii) Using (i), find expected frequencies (E) for each of the classes “0”, “1”, “2”, “3” 
and “4”. 
(iv) Compute standardised residuals (SR) given by SR = O−E√ 
for each of the 
classes “0”, “1”, “2”, “3” and “4’. 
(v) With reference to the SR values in (iv), comment on the goodness of fit of the 
fitted Poisson model. Hint: If |SR| < 2, then the fitted Poisson model is said 
to be a good model for the data. 
Use set.seed(100) to answer (b) and (c) below: 
(b) (i) Generate a random sample of size 25 from a normal distribution with mean, 
µ = 2.5 and standard deviation (sd), σ = 1.5. Now assume that these data come 
from a normal distribution with an unknown mean µ and a known sd, σ = 1.5. 
Based on this sample, find a 95% confidence interval (CI) for µ. 
(ii) Repeat the process in (i) 100 times and find the mean of these 100 means. Using 
your 100 samples, calculate 100 CIs for µ. How many of these 100 intervals would 
contain the true mean µ = 2.5? 
(c) Generate a random sample of size 25 from the exponential distribution with param- 
eter, λ = 5. Find the mean of your sample. Repeat this process 10000 times and 
draw the density curve for these 10000 means. Investigate whether this distribution 
for means agrees with the Central Limit Theorem. 
 
联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!