In: Statistics and Probability
(Using R Scholar) For each of the distributions, begin by creating 1000 random samples, each of size ?. Then, for each of the 1000 samples, you will calculate the sample average, ?̅. After calculating 1000 different ?̅’s, you will be able to make a histogram and normal probability plot of the ?̅ values and thus visualize the distribution of ?̅. The goal is to see what value of ? is large enough for the distribution of ?̅ to become approximately normal. Notice that this value of ? depends on the population distribution. To determine the value of ? required, your simulations will start from a small ? and progress to larger ?'s. You will assess the normality based on the plots for each ? and continue until either you have finished the values of ? listed or increased the values until observing sufficient normality in the plots.
For each of the distributions below, you will complete the following: (0.2 points) Code: You only need to provide one code listing for each distribution (i.e. you don’t need to repeat the code for each choice of ?).
2. (0.5 points) Histogram/normal probability plots For each of the values of ?, submit a histogram (with the two colored curves) and a normal probability plot. For each of the graph pairs, indicate whether they appear sufficiently normal or not. No explanation is required. Make sure you increase ? until the distribution of ?̅ appears sufficiently normal.
3. (0.3 points) Summary table This table contains the experimental mean and standard deviation calculated from the data (output is required for each value of ?) and the theoretical mean and standard deviation calculated from Equations 1 (with work for one of the values for each distribution where ? ≠ 1). The format for this table for Part B is below. Make sure you increase ? until the distribution of ?̅ appears sufficiently normal.
A. (1 points) Standard Normal Distribution. ? = 1, 3, 7 and 15.
B. (1 points) Uniform distribution over the interval (0, 8). ? = 1, 3, 7 and 15.
C. (1 points) Gamma distribution with parameters ? = ?. ?? and ? = ?. ? = 1, 5, 10, 20, 40, and continue in intervals of 20 if needed until the shape becomes normal. This distribution has population mean and standard deviation of ? = 1.805, ? = 0.95.
D. (1 points) Poisson distribution with parameter ? = ?. ?. ? = 1, 5, 10, 20, 40, and continue in intervals of 20 if needed until the shape becomes normal.
The required code is provided as follows,
*****************************************************************************************************************
##### Part A
n=c(1,3,7,15)
## sample size
m=array(dim=1)
par(mfrow=c(2,4))
for(j in n){
for (i in 1:1000){
x=rnorm(n)
## standard normal distribution
m[i]=mean(x)
s[i]=sd(x)
}
hist(m,xlab = "Xbar",main=paste("Histogram of Xbar with
n=",toString(j)))
lines(density(m))
qqplot(m,rnorm(1000),main = paste("sample size is
",toString(j)),xlab="Theoretical Quantiles",ylab="Distribution
Quantiles")
}
#######Part B.
n=c(1,3,7,15)
## sample size
m=array(dim=1)
par(mfrow=c(2,4))
for(j in n){
for (i in 1:1000){
x=unif(n,0,8)
## Uniform distribution in interval (0,8)
m[i]=mean(x)
s[i]=sd(x)
}
hist(m,xlab = "Xbar",main=paste("Histogram of Xbar with
n=",toString(j)))
lines(density(m))
qqplot(m,rnorm(1000),main = paste("sample size is
",toString(j)),xlab="Theoretical Quantiles",ylab="Distribution
Quantiles")
}
#######Part C.
n=c(1,5,10,20,40,60)
## sample size
m=array(dim=1)
par(mfrow=c(3,4))
for(j in n){
for (i in 1:1000){
x=rgamma(n,scale=3.61,shape=2)
## gamma distribution with alpha = 3.61, beta = 2
m[i]=mean(x)
s[i]=sd(x)
}
hist(m,xlab = "Xbar",main=paste("Histogram of Xbar with
n=",toString(j)))
lines(density(m))
qqplot(m,rnorm(1000),main = paste("sample size is
",toString(j)),xlab="Theoretical Quantiles",ylab="Distribution
Quantiles")
}
#######Part D.
n=c(1,5,10,20,40)
## sample size
m=array(dim=1)
par(mfrow=c(2,5))
for(j in n){
for (i in 1:1000){
x=rnorm(n)
## poisson distribution with lambda = 1.9
m[i]=mean(x)
s[i]=sd(x)
}
hist(m,xlab = "Xbar",main=paste("Histogram of Xbar with
n=",toString(j)))
lines(density(m))
qqplot(m,rnorm(1000),main = paste("sample size is
",toString(j)),xlab="Theoretical Quantiles",ylab="Distribution
Quantiles")
}
*********************************************************************************************************************
An example of the plot for Part A. i.e. for standard normal distribution is obtained as follows,
***************************************************PLEASE UPVOTE****************************************