Statistical Inference Course Project 1

Brandon Bartell

Part 1

Data Processing

We are interested in simulating averages of 40 random numbers taken from the exponential distribution.

nosim <- 1000
lambda<-0.2
expmn<-1/lambda
expsd<-1/lambda

plot(c(0,20),c(0,lambda),xlab="X",ylab="lambda {e}^{- lambda X}", main="Exponential Distribution for lambda=0.2",type="n")
lines(x=(0:300)/10,dexp((0:300)/10,rate=lambda))

plot of chunk unnamed-chunk-1

The exponential distribution function for lambda = 0.2

We randomly generated 1000 sets of 40 numbers from the exponential distribution and took their mean. We then subtracted the expected mean, 1/lambda, and divided by the standard error, sqrt(40)/lambda.

cfunc <- function(x, n) sqrt(n) * (mean(x) - expmn) / expsd
set.seed(10)
mat<-matrix(rexp(40*nosim,lambda),nrow=nosim,ncol=40)
dat <- apply(mat, 1, cfunc, 40)

g<- dat
m<-0
std<-1
hist(dat, density=20, breaks=20, prob=TRUE, 
     xlab="Normalized sample mean of 40 random numbers from the exponential distribution", main=" of 40 random exponentials")
curve(dnorm(x, mean=m, sd=std), 
      col="darkblue", lwd=2, add=TRUE, yaxt="n")

plot of chunk unnamed-chunk-2

This yields a normalized histogram that follows the overlayed standard normal distribution, centered at 0 with standard deviation 1.

Results

The normalized distribution in the figure above is centered at 0 with a standard deviation of 1, identical to the normal distribution. Since we subtracted by the mean and divided by the standard error, the un-normalized distribution is centered at 1/lambda and has a standard deviation of sqrt(40)/lambda.

Thus, the center of the mean of numbers randomly generated from the exponential distribution is the same as the population mean of the exponential distribution. The standard deviation of the simulated distribution is equal to the standard error of one simulation. The normalized simulated distribution of means closely agrees with the standard normal distribution.