this in r language The following code is a simulation of the central limit theorem. In the code we generate 36 observations from a random exponential distribution with mean 1 and variance 1. We then use a for loop to generate averages of these 36 observations to display in a histogram. Run the following code in R and select all answers that apply based on the code. I would also suggest running the code more than one as the numbers generated are random and results will vary slightly. CODE: #Generating data data.exp = rexp(36) par(mfrow=c(2,1)) hist(data.exp, main = 'Histogram of exponential with mean 1')
this in r language
The following code is a simulation of the central limit theorem. In the code we generate 36 observations from a random exponential distribution with mean 1 and variance 1. We then use a for loop to generate averages of these 36 observations to display in a histogram.
Run the following code in R and select all answers that apply based on the code. I would also suggest running the code more than one as the numbers generated are random and results will vary slightly.
CODE:
#Generating data
data.exp = rexp(36)
par(mfrow=c(2,1))
hist(data.exp, main = 'Histogram of exponential with mean 1')
#Gererate averages for the central limit theorem
#I.e. data set of averages
bar = c(1:500)#store the averages
for (i in c(1:500)) {
data.exp = rexp(36)
bar[i] = mean(data.exp)
}
hist(bar, main = 'Histogram of data set of averages for CLT')
sprintf("Theoretical mean of data.exp: %s", 1)
sprintf("mean of the average: %s", mean(bar))
sprintf("Theoretical variance of data.exp: %s", 1)
sprintf("variance of the average: %s", var(bar))
Trending now
This is a popular solution!
Step by step
Solved in 2 steps