rm(list=ls()) #clears memory setwd("/rstuff") #sets path x <- 1:5000 #number of iterations for "for" z1 <- NULL #creates a null set z2 <- NULL z3 <- NULL z4 <- NULL z5 <- NULL for(i in seq(along=x)) #loops x times {z1<-c(z1,mean(rnorm(10, mean=0, sd=1)))} # fills z with mean of 10 random draws from a # normal distribution with mean=0 and s=1 for(i in seq(along=x)) {z2<-c(z2,mean(rnorm(100, mean=0, sd=1)))} for(i in seq(along=x)) {z3<-c(z3,mean(rnorm(1000, mean=0, sd=1)))} for(i in seq(along=x)) {z4<-c(z4,mean(rnorm(10000, mean=0, sd=1)))} for(i in seq(along=x)) {z5<-c(z5,mean(rnorm(100000, mean=0, sd=1)))} zall <- cbind(z1,z2,z3,z4,z5) ln1 <- NULL #creates a null set ln2 <- NULL ln3 <- NULL ln4 <- NULL ln5 <- NULL mu <- 2 sd <- sqrt(2*(log(100)-mu)) for(i in seq(along=x)) #loops x times {ln1<-c(ln1,mean(rlnorm(10, meanlog=mu, sdlog=sd)))} # fills z with mean of 10 random draws from a # lognormal distribution with logmean=0 and logs=10 for(i in seq(along=x)) {ln2<-c(ln2,mean(rlnorm(100, meanlog=mu, sdlog=sd)))} for(i in seq(along=x)) {ln3<-c(ln3,mean(rlnorm(1000, meanlog=mu, sdlog=sd)))} for(i in seq(along=x)) {ln4<-c(ln4,mean(rlnorm(10000, meanlog=mu, sdlog=sd)))} for(i in seq(along=x)) {ln5<-c(ln5,mean(rlnorm(100000, meanlog=mu, sdlog=sd)))} lnall <- cbind(ln1,ln2,ln3,ln4,ln5) cltall <- cbind(zall,lnall) write.csv(cltall, file = "cltall.csv")