Question

In: Statistics and Probability

(Using R Scholar) For each of the distributions, begin by creating 1000 random samples, each of...

(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.

Solutions

Expert Solution

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


Related Solutions

In R, Draw 1000 samples from the following distributions and create histograms for each. Be sure...
In R, Draw 1000 samples from the following distributions and create histograms for each. Be sure to comment about each histogram. Remember all histograms should have four items addressed. (a) X ∼ N (0, 1) using rnorm function.   (b) X ∼ Gamma(2, 3) using the rgamma function. (c) X+Y where X ∼ N(5,2) and Y ∼ χ2(15). (d) X ∼ Binomial(1, 0.3). (e) Calculate a mean of a vector X = (X1, X2, ..., Xn ) 1000 times, where Xi...
a.) Use a t-distribution to answer this question. Assume the samples are random samples from distributions...
a.) Use a t-distribution to answer this question. Assume the samples are random samples from distributions that are reasonably normally distributed, and that a t-statistic will be used for inference about the difference in sample means. State the degrees of freedom used. Find the endpoints of the t-distribution with 2.5% beyond them in each tail if the samples have sizes n1=16 and n2=29 . Enter the exact answer for the degrees of freedom and round your answer for the endpoints...
How do I even begin to solve this using R statistical software? A random sample of...
How do I even begin to solve this using R statistical software? A random sample of eight pairs of twins was randomly assigned to treatment A or treatment B. The data are given in the following table: Twins 1 2 3 4 5 6 7 8 Treatment A 48.3 44.6 49.7 40.5 54.3 55.6 45.8 35.4 Treatment B 43.5 43.8 53.7 43.9 54.4 54.7 45.2 34.4 What is the p-value of the Wilcoxon signed-rank test? Is there any significant evidence...
How do I even begin to solve this using R? A random sample of eight pairs...
How do I even begin to solve this using R? A random sample of eight pairs of twins was randomly assigned to treatment A or treatment B. The data are given in the following table. Twins 1 2 3 4 5 6 7 8 Treatment A 48.3 44.6 49.7 40.5 54.3 55.6 45.8 35.4 Treatment B 43.5 43.8 53.7 43.9 54.4 54.7 45.2 34.4 What is the p-value of the Wilcoxon signed-rank test? Is there any significant evidence that the...
3. (3 pt) Use R functions to generate 1000 random samples from t-distribution with 15 degrees...
3. (3 pt) Use R functions to generate 1000 random samples from t-distribution with 15 degrees of freedom. Make a histogram with the samples showing the relative frequencies. Then overlay a probability density plot over this histogram.
Generate 200 random numbers using each of the following continuous distributions and plot the histograms (a)...
Generate 200 random numbers using each of the following continuous distributions and plot the histograms (a) Uniform (use A = 3 and B = 7) (b) Exponential (use population mean = 0.2) (c) Gamma (use parameters 3 and 2) (d) Normal (use µ = 2 and σ = 5) Attach the histogram plots and reflect on what you observe. Hint: Use RAND() to generate uniform random numbers and use inverse CDF to generate random numbers for each distribution.
A study using two random samples of 35 people each found that the average amount of...
A study using two random samples of 35 people each found that the average amount of time those in the age group of 26-35 years spent per week on leisure activities was 39.6 hours, and those in the age group of 46-55 years spent 35.4 hours. Assume that the population standard deviation for those in the first age group found by previous studies is 6.3 hours, and the population standard deviation of those in the second group found by previous...
Generate 1000 random numbers from ??3? starting with standard normal random numbers in R.
Generate 1000 random numbers from ??3? starting with standard normal random numbers in R.
What is the code in Rstudio or R? (a) Generate 200 random samples of size n...
What is the code in Rstudio or R? (a) Generate 200 random samples of size n = 10 from a Poisson distribution with mean λ = 12. i. Calculate sample means for each sample. Report the first 10 sample means. ii. Draw a histogram of the sample means (where the y-axis is the density) and fit a density estimate (default density estimator is ok). iii. What is your finding about the sampling distribution of the sample mean, based on your...
Generate 1000 random numbers from ??2, 5? starting with standard normal random numbers in R.
Generate 1000 random numbers from ??2, 5? starting with standard normal random numbers in R.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT