# takes a series of samples from a series of sample sizes and calculates the mean of the sample variability and the variance of the sample variability
population.size = 1000000
population.mean = 300
population.std = 50
plot.delay = 0.1
maxsample.size = 100
samplespersample.size = 50
meansample.var = 0
varsample.var = 0
sample.var = 0
population.data = rnorm(population.size,population.mean,population.std)
population.mean = mean(population.data)
par(mfrow=c(2, 1))
par(mar=c(1,1,1,1))
# plot more samples
for (plot.counter in 2:maxsample.size)
{
for (sample.counter in 1:samplespersample.size)
{
sample.data = sample(population.data,plot.counter,replace = TRUE)
sample.var[sample.counter] = var(sample.data)
}
meansample.var[plot.counter-1] = mean(sample.var)
varsample.var[plot.counter-1] = var(sample.var)
}
barplot(meansample.var)
title(main='Mean of Sample Variances')
barplot(varsample.var)
title(main='Variance of Sample Variances')