Statistical Inference Course Project Part I
Statistical Inference Course Project Part I
Simulation Exercise
A sample of 1000 replicates is generated from the mean of an exponential assimilation of 40 observations.
set.seed(100)
n <- 40
lambda <- 0.2
B <- 1000
Sample = NULL
for (i in 1 : B) Sample = c(Sample, mean(rexp(n,lambda)))
Distribution Graph
It can be observed that after generating the sample, the distribution of the mean of the imulations is 5 as it is
theoretically.
The histogram shows normal behavior, a normal distribution cross is added with the specification of mean and
standard deviation to indicate that effectively after the replicates the distribution of the means is approximately
normal.
library(scales)
hist(Sample, main = 'Histogram of Averages of 40 Exponentials over 1000 Simulations',
xlab='Mean',
freq = FALSE,
col=alpha('steelblue',0.7))
curve(dnorm(x,5,sd(Sample)),
from = 3, to = 9,
add = TRUE, lwd=3,
col = alpha('orange', 0.6))
abline(v=5,lwd=3,col= alpha('red', 0.7), lty=2)