#Project 2, Math 502. by Nasser Abbasi. R version populationSize = 1000; sampleSize = 30; nIter = 1000; population = seq(1,populationSize); currentEstimate = 0; for(i in 1:nIter){ s = sample(population,sampleSize,replace=T) currentEstimate = currentEstimate + (2*mean(s)-1) } print( currentEstimate / nIter )