Question: Rstudio programming : Let x = x1 + ... + x20, the sum of 20 independent Uniform(0,1) random variables. In R, create 1,000 simulations of

Rstudio programming :

Let x = x1 + ... + x20, the sum of 20 independent Uniform(0,1) random variables. In R, create 1,000 simulations of x and plot their histogram. On the histogram, overlay a graph of the normal density function with the same mean as x. Comment on any differences between the histogram and the curve. Hint 1: To plot a histogram in R you can build on the following code:

library(ggplot2)

df <- data.frame( x = rnorm(1000) )

ggplot(df, aes(x)) + geom_histogram(aes(y=..density..))

Hint 2: In ggplot you cannot plot the normal density as a function. But you can easily simulate lots of values drawn from a normal distribution (say 1,000) and plot these data as a geom_density(). The main challenge for you to figure out is how to use two ggplot layers, each with its own data.frame: The first layer uses the data from x the second uses data from the normal distribution.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!