title | author | output | ||||||
---|---|---|---|---|---|---|---|---|
Statistical Inference Course Project, Part 1: Simulation Exercises |
Sefa Kilic |
|
The exponential distribution can be simulated in R with rexp(n, lambda)
where
lambda
Let's do a thousand simulated averages of 40 exponentials.
set.seed(3)
lambda <- 0.2
num_sim <- 1000
sample_size <- 40
sim <- matrix(rexp(num_sim*sample_size, rate=lambda), num_sim, sample_size)
row_means <- rowMeans(sim)
The distribution of sample means is as follows.
The distribution of sample means is centered at 4.9866
and the theoretical center of the distribution is
Due to the central limit theorem, the averages of samples follow normal distribution. The figure above also shows the density computed using the histogram and the normal density plotted with theoretical mean and variance values. Also, the q-q plot below suggests the normality.
Finally, let's evaluate the coverage of the confidence interval for
The 95% confidence intervals for the rate parameter (