IliasS
1/23/2019
The application can be found here linked phrase The scope of the application is the visualization of the Central Limit Theorem validity for the exponential and uniform distribution.
1.With the application we can define the basic characteristics for two types of distributions the uniform or the exponential and create a random set of variables (population) which follow the one of the two distributions.
2.Then we can set the number of samples (populations) to be gathered with the same characteristics as define for the distribution under examination.
3.Using data created by the aforementioned choices we draw two plots, one histogram from one distribution and one histogram of means from populations which were gathered as samples.
4.In the end through the plot we can visualize that the CLT stand for both distributions
An example of the code that needed to create the two plots of the application for the exponential distribution are given in the following chunk.The first plot ia a histogram of an exponential with rate equal with 0.2 and with 40 observations. For the second plot we use the means from 1000 exponentials with the same characteristics (n=40,rate=0.2)
par(mfrow=c(1,2))
set.seed(1)
one_exp<-rexp(40,rate=.2)
simulation_e<-rexp(40000,rate=.2)
simmatrix_e<-(matrix(simulation_e,ncol = 1000,nrow = 40))
esamplemean<-apply(simmatrix_e,2,mean)
plot1<-hist(one_exp,density=40,breaks = 40,freq = FALSE,main = "plot1",
xlab = "Random Variables",ylab = "Density")
curve(dexp(x,.2),add = TRUE,lwd=5,from = 0)
plot2<-hist(esamplemean,density=40,breaks = 40,freq = FALSE,main = "plot2",
xlab = "Random Variables",ylab = "Density")
curve(dnorm(x,mean = 1/.2,sd=(1/0.2)/sqrt(40)),add=TRUE,lwd=5)
An example of the code that needed to create the two plots of the application for the uniform distribution are given in the following chunk.The first plot is histogram of a uniform with lower value equal with zero and upper equal with 40 and with 40 observations. For the second plot we use the means from 1000 uniforms with the same characteristics (n=40,min=0,max=40)
par(mfrow=c(1,2))
set.seed(5)
one_exp<-runif(40,min = 0,max = 40)
simulation_u<-runif(40000,min = 0,max = 40)
simmatrix_u<-(matrix(simulation_u,ncol = 1000,nrow = 40))
usamplemean<-apply(simmatrix_u,2,mean)
plot1<-hist(one_exp,density=40,breaks = 40,freq = FALSE,main = "plot1",
xlab = "Random Variables",ylab = "Density")
curve(dunif(x,min = 0,max = 40),add = TRUE,lwd=5,from = 0-10,to=40+10)
plot2<-hist(usamplemean,density=40,breaks = 40,freq = FALSE,main = "plot2",
xlab = "Random Variables",ylab = "Density")
curve(dnorm(x,mean = 40/2,sd=(40/sqrt(12))/sqrt(40)),add=TRUE,lwd=5)