# What is the probability of n people from a list of m people being in a random selection of x people from a list of y people?

If I am selecting 232 people from a pool of 363 people without replacement what is the probability of 2 of a list of 12 specific people being in that selection?

This is a random draw for an ultra race where there were 363 entrants for 232 spots. There is an argument about whether the selection was biased against a certain group of 12 people.

My initial attempt at calculating this was that there was 232 choose 363 possible selections. The number of combinations of any one person from the list of twelve is 1 choose 12 + 2 choose 12 + ... + 11 choose 12 + 12 choose 12. Thus 1 choose 12 + 2 choose 12 .... / 232 choose 363. Which ends up being a very low number which is clearly too low.

How do I calculate this?

-
Two technical points. First, you're now dealing with a likelihood rather than a probability as the outcome is known. Second, it doesn't matter what the theoretical likelihood is, given that you have a result. I think it would be better to approach the method used for selection: how were the selections chosen? You need to prove the correctness of the method, not the correctness of the result. – Michelle Mar 6 '12 at 21:23
One would view this as a likelihood, Michelle, for the purpose of estimating selection probabilities. That does not appear to be the case here. – whuber Mar 6 '12 at 22:43
You need to be careful in using the simple calculation of the hypergeometric RV, as the 12 people who are complaining are not randomly selected. They are complaining because they were not selected. – Guy Mar 8 '12 at 22:46

I interpret the question like this: suppose the sampling was purportedly carried out as if $363$ tickets of white paper were put in a jar, each labeled with the name of one person, and $232$ were taken out randomly after thoroughly stirring the jar's contents. Beforehand, $12$ of the tickets were colored red. What is the chance that exactly two of the selected tickets are red? What is the chance that at most two of the tickets are red?

An exact formula can be obtained, but we don't need to do that much theoretical work. Instead, we just track the chances as the tickets are pulled from the jar. At the time $m$ of them have been withdrawn, let the chance that exactly $i$ red tickets have been seen be written $p(i,m)$. To get started, note that $p(i,0)=0$ if $i\gt 0$ (you can't have any red tickets before you get started) and $p(0,0)=1$ (it's certain you have no red tickets at the outset). Now, on the most recent draw, either the ticket was red or it wasn't. In the first case, we previously had a chance $p(i-1,m-1)$ of seeing exactly $i-1$ red tickets. We then happened then to pull a red one from the remaining $363 - m + 1$ tickets, making it exactly $i$ red tickets so far. Because we assume all tickets have equal chances at every stage, our chance of drawing a red in this fashion was therefore $(12-i+1) / (363 - m + 1)$. In the other case, we had a chance $p(i,m-1)$ of obtaining exactly $i$ red tickets in the previous $m-1$ draws, and the chance of not adding another red ticket to the sample on the next draw was $(363 - m + 1 - 12 + i) / (363 - m + 1)$. Whence, using basic axioms of probability (to wit, chances of two mutually exclusive cases add and conditional chances multiply),

$$p(i,m) = \frac{p(i-1,m-1) (12-i+1) + p(i,m-1) (363 - m + 1 - 12 + i)}{363 - m + 1}.$$

We repeat this calculation recursively, laying out a triangular array of the values of $p(i,m)$ for $0\le i\le 12$ and $0 \le m \le 232$. After a little calculation we obtain $p(2,232) \approx 0.000849884$ and $p(0,232)+p(1,232)+p(2,232)\approx 0.000934314$, answering both versions of the question. These are small numbers: no matter how you look at it, they are pretty rare events (rarer than one in a thousand).

As a double-check, I performed this exercise with a computer 1,000,000 times. In 932 = 0.000932 of these experiments, 2 or fewer red tickets were observed. This is extremely close to the calculated result, because the sampling fluctuation in the expected value of 934.3 is about 30 (up or down). Here is how the simulation is done in R:

> population <- c(rep(1,12), rep(0, 363-12)) # 1 is a "red" indicator
> results <- replicate(10^6,
sum(sample(population, 232)))   # Count the reds in 10^6 trials
> sum(results <= 2)                          # How many trials had 2 or fewer reds?
[1] 948


This time, because the experiments are random, the results changed a little: two or fewer red tickets were observed in 948 of the million trials. That still is consistent with the theoretical result.)

The conclusion is that it's highly unlikely that two or fewer of the 232 tickets will be red. If you indeed have a sample of 232 of 363 people, this result is a strong indication that the tickets-in-a-jar model is not a correct description of how the sample was obtained. Alternative explanations include (a) the red tickets were made more difficult to take from the jar (a "bias" against them) as well as (b) the tickets were colored after the sample was observed (post-hoc data snooping, which does not indicate any bias).

An example of explanation (b) in action would be a jury pool for a notorious murder trial. Suppose it included 363 people. Out of that pool, the court interviewed 232 of them. An ambitious newspaper reporter meticulously reviews the vitae of everyone in the pool and notices that 12 of the 363 were goldfish fanciers, but only two of them had been interviewed. Is the court biased against goldfish fanciers? Probably not.

-
NB In the simulation, it does not matter that it is the very first 12 "tickets" that are marked, because all sampling is performed randomly without replacement (via sample). In effect, at each iteration sample thoroughly mixes the tickets each time it is called before it withdraws 232 of them. – whuber Mar 6 '12 at 23:19
Goodness - that wasn't actually the result I expected. Thank you for your thorough work and good explanation. (Curiously, I actually did some stats training at the University of Auckland where R was first developed) – Sarge Mar 7 '12 at 0:56

@whuber gave an exhaustive explanation, I just want to point out that there is a standard statistical distribution corresponding to this scenario: the hypergeometric distribution. So you can obtain any such probabilities directly in, say, R:

Probability of exactly 2 out of 12 selected:

   > dhyper(2, 12, 363-12, 232)
[1] 0.0008498838


Probability of 2 or fewer out of 12 selected:

   > phyper(2, 12, 363-12, 232)
[1] 0.000934314

-
+1 Thanks. I should have mentioned this connection. The hypergeometric distribution classically appears in sampling-resampling experiments. The 12 specific people (my "red tickets") are like fish that have been caught, marked, and thrown back into the pool; the sample of 232 is like the set of fish that are subsequently caught. The hypergeometric distribution describes the frequencies of recaptured fish. – whuber Mar 7 '12 at 15:15

The odds are much higher than calculated with the simple hypergeometric distribution, as the group is not chosen randomly ("12 fish are painted red before the draw").

From the description of the question, we are testing for a fraud in the draw. A specific group of 12 people complained that only 2 of them were selected, while the expected number was 232/363~2/3=8.

What we really need to calculated is what are the odds that "No group of size 12 will have only 2 member selected". The odds that at least one group will have 2 or fewer (therefore will complain against the fairness of the draw) are much higher.

When I run this simulation, and check in how many of the trials none of the 30 (=360/12) groups had 2 or fewer selections, I get about 2.3% of the times. 1:42 is low but not impossible.

You should still check the procedure of the draw as it might be biased against a specific group of people. They might have come together and received a range of the draw with less probability (the first or last numbers, for example), or whatever dependent variable on the procedure of the draw. But if you don't find any flaw in the procedure, you can return to the 1:42 odds that it is simply bad luck for the group.

-
A good point, BUT (a) surely not every possible group of 12 has enough similarity to matter, and (b) not all groups that have enough similarity to matter have exactly 12 members. – zbicyclist Mar 9 '12 at 15:21
@zbicyclist, I don't claim that the calculation is accurate. I wanted to give a reasonable doubt (as we are in the realm of the law with fraud detection), that the draw is not guilty. – Guy Mar 9 '12 at 15:33