# demonstrates the concept of variance using scatter plots # the script will generate two samples from two populations, each with the same mean but a different # standard deviation # the population size, the means of the populations, and the standard deviations of the populations. note # population1 has a much smaller standard deviation than population2. population.size = 1000000 population.mean1 = 0 population.std1 = 50 population.mean2 = 0 population.std2 = 500 # create two populations population.data1 = rnorm(population.size,population.mean1,population.std1) population.data2 = rnorm(population.size,population.mean2,population.std2) # draw out a sample from each population in the x and y axis sample.size = 100 sample.data1 = sample(population.data1,sample.size,replace = TRUE) sample.data2 = sample(population.data2,sample.size,replace = TRUE) # plot the output axis.limit = 1000 par(mfrow=c(2, 1)) par(mar=c(1,1,1,1)) plot(sample.data1,ylim = c(-axis.limit,axis.limit)) plot(sample.data2,ylim = c(-axis.limit,axis.limit))