3. (3 pt) Use R functions to generate 1000 random samples from t-distribution wi
ID: 3069331 • Letter: 3
Question
3. (3 pt) Use R functions to generate 1000 random samples from t-distribution with 15 degrees of freedom. Make a histogram with the samples showing the relative frequencies. Then overlay a probability density plot over this histogram.3. (3 pt) Use R functions to generate 1000 random samples from t-distribution with 15 degrees of freedom. Make a histogram with the samples showing the relative frequencies. Then overlay a probability density plot over this histogram.
3. (3 pt) Use R functions to generate 1000 random samples from t-distribution with 15 degrees of freedom. Make a histogram with the samples showing the relative frequencies. Then overlay a probability density plot over this histogram.
Explanation / Answer
Find below the R code with comments. I assume that you are knowledgeable regarding the theory behind t-dictribution.
x=rnorm(1000) #generate 1000 random values
hist(x, main="1.2a Histogram of 1000 Random N(0,1) Values") #plot histogram
x.grid=seq(-3,3,.01) # create vector of x values
v.sim=(rnorm(1000))^2 + (rnorm(1000))^2 + (rnorm(1000))^2
t.sim = x / sqrt(v.sim/15) # t-distribution of the 1000 random values with 15 degrees of freedom (formulae)
#plotting histogram of t-distribution
hist(t.sim,probability="TRUE", nclass=50,
main="4.2b Histogram of 1000 Random t(df=15) Values (density scale)")
#Probability density graph
t.grid=seq(min(t.sim),max(t.sim),.01) #Create vector of x values
density.t.grid=dt(t.grid,df=15) # Compute vector of corresponding density values
lines(t.grid,density.t.grid,col='blue') # use R function lines() to add to current plot
I hope this will give you the desired graph.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.