Taking the reworded question as a starting point:
A) What is the chance of getting all males in one group (treatment/control) while there are all females in the other for different sample sizes?
n=1, the chance of picking a male from the population is
n=2, the chance that the first pick is a male is 0.5. The chance that the second pick is a male as wel is also
0.5. Consequently the chance of picking all males in a sample of 2 is
0.5 * 0.5, which is the same as
To put it more generally: the chance of picking all males in a sample is
0.5^n (in which n = sample size). The same is true for the chance of picking all females:
Now the chance of having all males in one group and all females in the other group is the product of these chances:
(0.5^n) * (0.5^n). When you want to take a more general approach, the case where it doesn't matter which sex is in the control group as long as the the other group is composed of the other sex, than the formula is
(0.5^(n-1)) * (0.5^n).
B) What is the chance that students in one group are from the same grade, while the student from the other group are all from one of the other grades?
Building on (A), the chances for the first group (=grade) seem quite simple to calculate. As the population is equally divided among the four groups, the chance of picking a student from a particular group is 0.25. So you would say that the chance is
0.25^n. However, this is not true. As it doe not matter from which group the first pick of a sample comes from, only the following picks do matter. The first pick determines from which group the following pick have to come. The chances that these following picks are from the same group are 0.25 for each pick. The chances of picking students from the same group is therefore
Now you want to know what the cahnces are that you pick students all from one of the other group. The chance for your first pick is
0.75. As the following picks have to be from the same group, the chance for each of these picks is
0.25. The chances of picking students for the second from another, but the same, group is
0.75 * (0.25^(n-1))
The chance of picking students from the same grade for the first group, while picking students from another, but the same, grade for the second group is therefore:
(0.25^(n-1)) * (0.75 * (0.25^(n-1)))
C) What is the chance of having all vegetable eaters in one group and all non-vegetable eaters in the second group?
For this question you have to calculate the change of picking a (non)-vegetable eater first. The chance of picking a vegetable eater is
0.5 for males and
0.75 for females. Because the population is equally divided betwwen male and females, the chance of picking a vegetable eater is:
(0.5 * 0.5) + (0.75 * 0.5) = 0.625. The chance of picking a non-vegetable eater is:
1 - 0.625 = 0.375
The chance of picking all vegetable eaters in the first group while in the same time picking all non-vegetable eaters for the second group is:
(0.625^n) * (0.375^n)
You can calculate the answers for A, B & C in R with the following code:
nr <- as.data.frame(c(3, 4, 5, 10, 100))
names(nr) <- c("sample.size")
nr$A <- (0.5 ^ (nr$sample.size - 1)) * (0.5 ^ nr$sample.size)
nr$B <- (0.5 ^ (nr$sample.size - 1)) * (0.75 * (0.25 ^ (nr$sample.size - 1)))
nr$C <- (0.625 ^ nr$sample.size) * (0.375 ^ nr$sample.size)
This will produce a dataframe with sample size in the first column and the probabilities for A, B & C in their respective columns.
Why you should use n-1 instead of simply multiplying by 2:
Consider the example of two group with
n = 3 each. When you start selecting the first group, it does not matter which sex you select. So your chance of picking the right one is
1. However, the outcome of your first pick determines which outcomes of the following two selections you need for a same sex group. The chances of picking the same sex for both selections are 0.5. Consequently the chance of picking participants of the same sex for the first group is
1*0.5*0.5 = 1*(0.5^2) = 0.5^2. The general formula for this outcome is
0.5^(n-1). For your second group, you have only a chance of
0.5 for the first pick of selecting a participant of the other sex. Also for the second and third pick you have a chance of
0.5 for each. The calculation is therefore:
0.5*0.5*0.5 = 0.5^3. The general formula for this part is
0.5 ^ n. As a result, the chance of selecting the first group of the same sex and the other group of the other sex is
(0.5^(n-1)) * (0.5^n).
I did some testing with different variations of the formula. In your specific setup the formula
(0.5^n) * (0.5^n) * 2 gives the same outcome. The caveat is in the individual chances. When you have for example a population with 40% males and 60% females, just multiplying with 2 will give you the wrong probability. Therefore working with
n-1 is the right solution.
When you add the following lines of code to the code above, you can see it action:
nr$Aa <- (0.5 ^ nr$sample.size) * (0.5 ^ nr$sample.size) * 2
nr$Ab <- (0.4 ^ (nr$sample.size - 1)) * (0.6 ^ nr$sample.size)
nr$Ac <- (0.4 ^ nr$sample.size) * (0.6 ^ nr$sample.size) * 2