> 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 ) [1] 1002.467 >