Tutorials › Statistical Theory I - Probability and Distribution Theory › Hypergeometric Probabilities by Counting

Geometric and Count Distributions · Tutorial 136 of 994

Hypergeometric Probabilities by Counting

Learn to count favorable samples and divide by the total number of possible samples to find hypergeometric probabilities.

Beginner 9 min read

What You'll Learn

  • Set up a hypergeometric model from a finite population and a simple random sample.
  • Derive the probability of exactly a specified number of successes using combinations.
  • Identify when an observed success count has probability zero because it is outside the support.
  • Calculate exact-count, at-least, and at-most probabilities by summing mass-function values.
  • Check that hypergeometric probabilities sum to one by counting all possible samples.

Counting Samples to Find Probabilities

When a sample is drawn without replacement from a finite population, the outcomes of successive draws are dependent: an object selected on one draw is no longer available on the next. To find the distribution of the number of successes, we can count the possible samples directly. The key is to specify what counts as a distinct sample and why all such samples are equally likely.

Suppose a population contains \(N\) distinct objects, of which \(K\) are designated successes and \(N-K\) are failures. Select \(n\) objects by simple random sampling without replacement, so each subset of \(n\) objects has the same probability of selection. Let \(X\) be the number of successes in the selected sample. The earlier material on hypergeometric sampling and its support identifies which values \(X\) can take; here we derive their probabilities by counting.

Definition: For integers \(N,K,n\) satisfying \(0\leq K\leq N\) and \(0\leq n\leq N\), the hypergeometric random variable \(X\) counts the successes in a uniformly selected subset of size \(n\) from a population of \(N\) distinct objects containing \(K\) successes. The total number of possible samples is \(\binom{N}{n}\). The number of samples with exactly \(x\) successes is \(\binom{K}{x}\binom{N-K}{n-x}\).

The binomial coefficient \(\binom{a}{b}\) counts the subsets of size \(b\) from \(a\) distinct objects when \(a\) and \(b\) are integers with \(0\leq b\leq a\). A count is zero if the requested number of objects cannot be chosen. Thus an exact count \(x\) is possible only when \(0\leq x\leq K\) and \(0\leq n-x\leq N-K\). Equivalently, the support is \( \max(0,n-(N-K))\leq x\leq \min(n,K) \), with integer \(x\).

Deriving the Hypergeometric Mass Function

A sample is an unordered subset: selecting the same four objects in a different order does not create a different sample. Because every subset of size \(n\) is equally likely, the probability of an event is the number of subsets in that event divided by \(\binom{N}{n}\), the number of all possible subsets. To have exactly \(x\) successes, choose \(x\) of the \(K\) successes and \(n-x\) of the \(N-K\) failures. These choices determine one sample, and every sample with exactly \(x\) successes is obtained in this way.

Theorem: Under simple random sampling without replacement from \(N\) distinct objects containing \(K\) successes, the probability mass function of the success count \(X\) is
$$ P(X=x)=\frac{\binom{K}{x}\binom{N-K}{n-x}}{\binom{N}{n}} $$
for integer \(x\) in the support \( \max(0,n-(N-K))\leq x\leq\min(n,K) \). For all other integer values of \(x\), \(P(X=x)=0\).

The numerator counts favorable samples and the denominator counts all possible samples. This argument also shows why the formula has two combination factors in its numerator: successes and failures must both be selected to form a sample of size \(n\). In particular, \(\binom{K}{x}\) alone does not count complete samples; it only chooses the successes.

The same counting argument verifies that the probabilities sum to one. Every subset of size \(n\) contains exactly one possible number \(x\) of successes. Grouping all subsets by that number partitions the full set of samples into disjoint groups.

Result: The hypergeometric masses over the support sum to one:
$$ \sum_{x=\max(0,n-(N-K))}^{\min(n,K)} \binom{K}{x}\binom{N-K}{n-x} =\binom{N}{n}. $$
Proof: Count all subsets of size \(n\) from the \(N\) objects. There are \(\binom{N}{n}\) in total. Alternatively, first classify a subset by its number \(x\) of successes. For each feasible \(x\), there are \(\binom{K}{x}\) ways to choose its successes and \(\binom{N-K}{n-x}\) ways to choose its failures. Multiplying gives the number of subsets in that group. The groups are disjoint, and together include every subset, so adding their sizes gives the displayed identity. Dividing both sides by \(\binom{N}{n}\) proves that the mass-function probabilities sum to one. \(\square\)

Worked Probability Calculations

Worked Example: Exactly Two Successes in a Sample

A box contains 12 labeled components, 5 of which are defective and 7 of which are good. Four components are selected uniformly without replacement. Let \(X\) be the number of defective components. Find \(P(X=2)\).

There are \(\binom{12}{4}\) possible samples. For exactly two defectives, choose 2 of the 5 defective components and 2 of the 7 good ones. Hence

$$ P(X=2) =\frac{\binom{5}{2}\binom{7}{2}}{\binom{12}{4}} =\frac{10\cdot21}{495} =\frac{210}{495} =\frac{14}{33} \approx 0.4242. $$

The support runs from 0 to 4, since four components are sampled and both population categories contain at least four and at least two objects, respectively. Thus two defectives is a feasible count. The probability is about \(42.42\%\).

Worked Example: At Least Two Successes

A shipment contains 20 devices, 6 of which fail a test and 14 of which pass. A quality inspector selects 5 devices uniformly without replacement. Find the probability that at least 2 fail.

Here \(N=20\), \(K=6\), and \(n=5\). The event includes the disjoint outcomes \(X=2,3,4,5\), so its probability is the sum of their individual probabilities. The total number of samples is \(\binom{20}{5}=15{,}504\). The favorable counts are:

$$ \begin{aligned} X=2 &: \binom{6}{2}\binom{14}{3}=15\cdot364=5{,}460,\\ X=3 &: \binom{6}{3}\binom{14}{2}=20\cdot91=1{,}820,\\ X=4 &: \binom{6}{4}\binom{14}{1}=15\cdot14=210,\\ X=5 &: \binom{6}{5}\binom{14}{0}=6\cdot1=6. \end{aligned} $$

Adding these disjoint counts gives \(5{,}460+1{,}820+210+6=7{,}496\) favorable samples. Therefore,

$$ P(X\geq2) =\frac{7{,}496}{15{,}504} =\frac{937}{1{,}938} \approx0.4835. $$

The support is \(0,1,2,3,4,5\), so the four terms used above cover every possible outcome in the event. Counts outside the event, namely 0 and 1, are not included.

Worked Example: At Most One Success

A tray contains 15 blood-test specimens, 4 of which have a particular marker and 11 of which do not. Three specimens are selected uniformly without replacement. Find the probability that at most one selected specimen has the marker.

The event consists of \(X=0\) or \(X=1\). There are \(\binom{15}{3}=455\) possible samples. With no marked specimens, all 3 must be chosen from the 11 without the marker, giving \(\binom{4}{0}\binom{11}{3}=1\cdot165=165\) samples. With exactly one marked specimen, there are \(\binom{4}{1}\binom{11}{2}=4\cdot55=220\) samples. Thus

$$ P(X\leq1) =\frac{165+220}{455} =\frac{385}{455} =\frac{11}{13} \approx0.8462. $$

The event count \(385\) cannot exceed the total \(455\), as it should not: the remaining \(455-385=70\) samples have two or three marked specimens. This provides a direct arithmetic check on the count.

A Reliable Counting Procedure

For a specified hypergeometric probability, a short sequence of decisions prevents most errors. First identify what constitutes a success and confirm that the sample is drawn uniformly without replacement. Then translate the event into possible values of \(X\), and count complete samples for each value. For an event involving several counts, add their favorable counts or, equivalently, add their probabilities. The following procedure is especially useful when a question asks for an exact count or a tail probability.

1
Record the population quantities.
Write down \(N\), \(K\), and \(n\), along with which population members count as successes.
2
Translate the event.
For an exact event, use one value \(x\). For “at least” or “at most,” list every feasible value included in the event.
3
Count and divide.
For each feasible \(x\), count \(\binom{K}{x}\binom{N-K}{n-x}\) favorable samples. Divide the total favorable count by \(\binom{N}{n}\).
4
Check the result.
Confirm that all included counts are in the support, that favorable samples do not outnumber all samples, and that the final probability lies between 0 and 1.

Common Mistake: Counting Ordered Draws

A frequent error is to treat a sample of \(n\) objects as an ordered sequence in the denominator while treating it as an unordered subset in the numerator. For example, one might use \(N(N-1)\cdots(N-n+1)\) as the total number of outcomes but use \(\binom{K}{x}\binom{N-K}{n-x}\) for favorable outcomes. These quantities count different kinds of objects, so their ratio is not the desired probability.

There are two consistent approaches. The one used here treats the sample as an unordered subset, giving \(\binom{N}{n}\) total samples and \(\binom{K}{x}\binom{N-K}{n-x}\) favorable samples. Alternatively, one could count ordered draw sequences in both numerator and denominator; every subset then corresponds to \(n!\) orderings. The common factor cancels, producing the same probability. Mixing the approaches does not preserve that cancellation.

A related error is to multiply \(n\) probabilities as though the draws were independent. In sampling without replacement, the chance that the next draw is a success changes after each object is removed. The subset-counting method handles that dependence without needing to calculate a separate sequence of conditional probabilities.

Key takeaway: A hypergeometric probability is a ratio of counts of complete samples: count all size-\(n\) subsets for the denominator, and count the subsets matching the requested success count for the numerator. For a multi-count event, combine the disjoint favorable groups.

Check Your Understanding

Use the counting method to answer each question. State the total number of samples and the favorable count or counts.

  1. A population has 10 objects, 3 of them successes. A sample of size 2 is selected uniformly without replacement. Find the probability of exactly one success.
  2. For \(N=18\), \(K=5\), and \(n=4\), which integer values of \(X\) have positive probability?
  3. In the setting of question 2, write the sum of combination counts that gives the number of samples with at least two successes.
  4. Explain why \(\binom{K}{x}\) alone does not count all samples with exactly \(x\) successes.
  5. If every possible size-\(n\) sample is assigned the same probability, why must the favorable count be divided by \(\binom{N}{n}\)?