3. (3 pt) Use R functions to generate 1000 random samples from t-distribution with 15 degrees of...

Free

70.2K

Verified Solution

Question

Basic Math

3. (3 pt) Use R functions to generate 1000 random samples fromt-distribution with
15 degrees of freedom. Make a histogram with the samplesshowing the relative
frequencies. Then overlay a probability density plot over thishistogram.

Answer & Explanation Solved by verified expert
3.6 Ratings (604 Votes)

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\n (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.


Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students