**Simple Random Sampling** is the purest form of probability sampling. *Each member of the population has an equal and known chance of being selected.* When there are very large populations, it is often difficult or impossible to identify every member of the population, so the pool of available subjects becomes biased.

In most cases, we conduct the sampling in a "*without*-replacement" manner, i.e. we don't put *back* the sample points once we pick them out. Correspondingly there is another way "sampling *with* replacement": every time before we do the sampling, we put all the individuals back again; although this is rare in practical sampling work, it's also extremely important and closely related to the idea of bootstrapping.

Of couse here we only discuss the case of "Simple Random Sampling Without Replacement".

One function is enough for us; that is *sample()*. This function can help us draw a random sample from a population (usually a vector containing some elements) with or without replacement.

For example:

> sample(1:10, 5) # randomly draw 5 elements from 1:10 [1] 3 6 9 8 2 > sample(1:10, 5) # again! the sample changed! [1] 2 10 7 5 8 > sample(1:10) # just a permutation; i.e. sample 10 elements from 1:10 [1] 6 4 3 2 7 9 5 10 8 1 > sample(1:10, 5, replace = T) # with replacement; two 1s [1] 6 5 3 1 1

If you've understanded what the function *sample()* means, let's move on the animtaions for SRSWOR below.

Here is a sequence of simple random sampling:

R code:

x = cbind(rep(1:10, 10), gl(10, 10)) par(mar = rep(0.1, 4)) for (i in 1:100) { plot(x, pch = 19, col = "blue", axes = F, ann = F) points(x[sample(100, 15), ], col = "red", cex = 3, lwd = 2) Sys.sleep(1) }

I used 15 random numbers from 1:100 to index the sample points, then added these points to the existing graph by *points()*. The animation was at last generated through looping.

There's a function *sample.simple()* in the package animation for the demonstration of the simple random sampling without replacement. Please check the help file or the vignette of this package.