0% found this document useful (0 votes)
42 views

Statistical Inference Course Project Part I

1000 samples of the means of an exponential distribution with λ=0.2 were generated using a for loop. The sample mean and variance were calculated and found to be close to the theoretical mean of 5 and variance of 0.625. A histogram of the sample shows a normal distribution, indicating the distribution of the means is approximately normal as expected theoretically.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Statistical Inference Course Project Part I

1000 samples of the means of an exponential distribution with λ=0.2 were generated using a for loop. The sample mean and variance were calculated and found to be close to the theoretical mean of 5 and variance of 0.625. A histogram of the sample shows a normal distribution, indicating the distribution of the means is approximately normal as expected theoretically.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Statistical Inference Course Project Part I

Mateo Córdoba Toro


7/10/2020
1000 samples of the means of the exponential distribution are generated using a for , then the mean and
variance are calculated, finally the respective distribution of the samples is plotted reflecting their normal behavior.

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)))

Sample mean vs Theorical mean


The standard deviation formula is used to find the variance, both theoretically and empirically. the variance has a
small deviation, however it is minimal and tends to the theoretical value.

'Sample mean' <- round(mean(Sample),3)


'Theorical mean '<- round(1/lambda)
'Sample var ' <- round(var(Sample),3)
'Theorical var' <- (1/lambda)^2/n
cbind(`Sample mean`,`Theorical mean `)

## Sample mean Theorical mean


## [1,] 5 5

cbind(`Sample var `, `Theorical var`)

## Sample var Theorical var


## [1,] 0.643 0.625

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)

You might also like