关键词 > STAT3023/3923/4023

STAT 3023/3923/4023 Statistical Inference

发布时间:2021-11-06

Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit


STAT 3023/3923/4023

Semester 2

Statistical Inference

2021


Computer Lab Week 4

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.