辅导案例-STAT3023/3923
STAT3023/3923 Statistical Inference Semester 2, 2020
Computer Lab Week 4
Due by 23:59 Sunday 20 September
Please include in your report all the code, plots, and any comments required by the questions.
The upload format will be restricted to pdf, html, or word, created any way that is convenient as
long as it includes all the required content.
1. (a) Generate 100 iid Unif(0,1) (use runif) random variables and store them in u. Apply
the function − log(1− u) to each element, and store the results in x.
(b) Plot the histogram of x and overlay it with the density curve of exponential(1) (use
dexp(x,rate=1)) . Why do we have good agreement here? (Hint: − log(1 − u) is
the inverse function of the c.d.f. of exponential(1).)
2. Transformation of random variables.
(a) Generate 100 random variables from a t distribution with 5 degrees of freedom (use
rt(100,df=5)). Store them in t. Make another vector f by f <- t^2. Overlay
the histogram of f with the density curve of a F1,5 distribution (use df(x, df1=1,
df2=5)). Comment on the plot.
(b) Generate 100 random variables from a F5,2 disrtibution (use rf(100, df1=5, df2=2)).
Store them in y. Make another vector w <- 1/y. Overlay the histogram of w with
the density curve of a F2,5 distribution. Comment on the plot.
(c) Generate 100 random variables from a beta(2, 1) distribution (use rbeta(100, shape1=2,
shape2=1)). Store them in z. Make another vector v <- 2*z/(4*(1-z)). Overlay
the histogram of v with the density curve of a F4,2 distribution. Comment on the
plot.
Copyright c© 2020 The University of Sydney
51作业君 51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: ITCSdaixie