In: Statistics and Probability
Suppose the height of individuals in a population follow a normal distribution with a mean (μ) of 66 inches and a standard deviation (σ) of 4 inches.
a) Using the statistical software R, sample n individuals from the distribution described above. For N=10,000 iterations, compute the average height for n=5, n=15, n=50, n=100 individuals and plot a histogram of the sampling distribution of the Z score (?̅−??/√? )
b) Using the statistical software R, sample n individuals from the distribution described above. For N=10,000 iterations, compute the average height for n=5, n=15, n=50, n=100 individuals and plot a histogram of the sampling distribution of the statistic (?̅−??/√? )
c) Compare the mean and variance of the sampling distributions above for n=5, n=15, n=50, n=100. What do you notice about these distributions?
solution:
Given data:
The R code is as follows:
set.seed(123)
N=10000
mu=66;sigma=4
n=5
X=0;Z=0;T=0
for(i in 1:N)
{
X[i]=rnorm(5,mu,sigma)
}
X_bar=mean(X);X_bar
S=sqrt(var(X));S
for(i in 1:N)
{
Z[i]=sqrt(n)*(X[i]-mu)/sigma
T[i]=sqrt(n)*(X[i]-mu)/S
}
hist(Z)
hist(T)
mean(Z);mean(T)
var(Z);var(T)
##########################
You can yourself see the histograms of Z and T which will be of standard normal distribution and student's t distribution (with n-1 d.f.) respectively.
You can see the following output until you keep the seed at 123 as in set.seed(123)
> mean(Z);mean(T)
[1] 0.002969464
[1] 0.002947943
> var(Z);var(T)
[1] 5.073267
[1] 5
For n=15, the outputs will be:
> mean(Z);mean(T)
[1] 0.005143262
[1] 0.005105988
> var(Z);var(T)
[1] 15.2198
[1] 15
For n=50, the output will be:
> mean(Z);mean(T)
[1] 0.009390268
[1] 0.009322215
> var(Z);var(T)
[1] 50.73267
[1] 50
For n=100, the output will be:
> mean(Z);mean(T)
[1] 0.01327984
[1] 0.0131836
> var(Z);var(T)
[1] 101.4653
[1] 100
From the above results it can be seen that the mean of the sampling distributions of Z as well as T are nearly zero though that slightly increases as n increases. Also the variance of the sampling distribution of Z is almost same as the value of n and that of T is exactly same as the value of n.
please give me thumb up