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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started