In the R document I explained the paired test first. It happens that I wrote the section for the unpaired test first here.

One of the easiest types of statistical hypothesis test to explain is a randomization test. If we have collected responses under two different conditions and the allocation of conditions has been randomized then a test of, say, $H_0:\mu_1=\mu_2$ versus $H_a:\mu_1<\mu_2$ can be based upon the sums of all possible subsets of the same size from the set of response values. Under the null hypothesis, the sample mean of the particular subset of size $k$ from the responses that we saw for the first condition should be similar to the population of sample means of subsets of size $k$ of the set of responses. Under the alternative hypothesis the sample mean from the combination of responses we saw should be on the low end of the populations of sample means from all possible subsets of size $k$.

One way to check this is simply to enumerate all possible subsets of size $k$ and evaluate their sums. (Because the subset size, $k$, is constant we work with the sums rather than the means, which are the sums divided by $k$.)

In the first chapter of Bob Wardrop's course notes for Statistics 371 he describes a student's experiment to determine if her cat prefers tuna-flavored treats or chicken-flavored treats.

The experiment lasted for 20 days. The assignment of chicken or tuna flavro was randomized, subject to the constraint that each flavor is provided exactly 10 times. According to the randomized selection, the tuna flavor would be given on