# The function c() in R concatenates scalars or vectors into a vector and takes as many argument as you want.
for(i in c(5,50)) # First run all code in this loop with i = 5; then with i=50
{
# Create empty vectors of numeric data to store each of our 500 sample means
unifData = numeric(500)
binData = numeric(500)
expData = numeric(500)
poisData = numeric(500)
# Recall that : is the range operator in R, so 1:500 will give you vector range of integers from 1 to 500
for(j in 1:500) # Run the code in this loop 500 times, starting with j=1 and moving 1 by 1 to j=500
{
unifData[j] = mean(runif(i,0,5)) # sample mean of i draws from uniform dist [0,5] is stored in index j of the vector
binData[j] = mean(rbinom(i,15,0.2)) # sample mean i draws from binom dist, n=15, p=0.2 is stored in index j of the vector
expData[j] = mean(rexp(i,5)) # sample mean of i draws from exp dist, lambda=5, is stored in index j of the vector
poisData[j] = mean(rpois(i,2)) # sample mean of i draws from pois dist, (mu? again, typically lambda)=2, is stored in index j of the vector
}
# Okay, so now each of my vectors contains a series of 500 sample means
print(paste("With i =",i," the results I get are:"))
print(paste("Mean of unifData: ",mean(unifData)))
print(paste("Mean of binfData: ",mean(binData)))
print(paste("Mean of expData: ",mean(expData)))
print(paste("Mean of poisData: ",mean(poisData)))
# Probably put your code to calculate variances of the samples here
}