Tutorials › VEE Mathematical Statistics › Calculating Exact Hypergeometric Probabilities

VEE Mathematical Statistics · Hypergeometric and Discrete Uniform Models · Tutorial 128 of 880

Calculating Exact Hypergeometric Probabilities

Calculate the probability of exactly a specified number of successes in a sample without replacement, including careful evaluation and simplification of combinations.

Intermediate 10 min read

What You'll Learn

  • Identify the population, number of successes, sample size, and target count in a sampling problem.
  • Apply the hypergeometric probability formula to an exact-count event.
  • Evaluate combinations accurately using products, factorials, or cancellation.
  • Check that a target count is feasible before calculating.
  • Recognize errors caused by replacement assumptions or an incorrect denominator.

Why Exact Hypergeometric Probabilities Require Careful Counting

When a sample is drawn without replacement, the chance of success changes as each item is selected. For an exact-count question, the reliable approach is to count the samples that meet the requirement and divide by the number of samples that could have been drawn. The main arithmetic challenge is often evaluating and simplifying combinations correctly.

This method applies when a finite population contains two categories, the sample is a simple random sample of a fixed size, and every sample of that size is equally likely. A sample might be a group of inspected items, selected records, or people chosen from a finite group. The category called a “success” is simply the one being counted; it need not be a favorable outcome.

Definition: Suppose a population contains \(N\) objects, of which \(K\) are designated successes. A simple random sample of size \(n\) is selected without replacement. If \(X\) is the number of successes in that sample, then \(X\) has a hypergeometric distribution with parameters \(N\), \(K\), and \(n\). For a feasible exact count \(k\), $$ P(X=k)=\frac{\binom{K}{k}\binom{N-K}{n-k}}{\binom{N}{n}}. $$

The numerator has two factors. The term \(\binom{K}{k}\) counts the ways to choose the \(k\) successes, and \(\binom{N-K}{n-k}\) counts the ways to choose the remaining \(n-k\) nonsuccesses. Their product counts the samples with exactly \(k\) successes. The denominator \(\binom{N}{n}\) counts every possible sample of size \(n\).

A combination is defined, for integers \(a\) and \(b\) with \(0\le b\le a\), by $$ \binom{a}{b}=\frac{a!}{b!(a-b)!}. $$ It counts unordered selections: the order in which items are selected does not produce a different sample. The formula for an exact count is applicable only when \(0\le k\le K\) and \(0\le n-k\le N-K\). Equivalently, the target count must be possible given both category totals and the sample size.

A Counting Justification

The formula follows directly from equally likely samples. There are \(\binom{N}{n}\) different subsets of size \(n\), and simple random sampling gives each subset the same probability. To form a subset with exactly \(k\) successes, choose \(k\) of the \(K\) success objects and \(n-k\) of the \(N-K\) nonsuccess objects. Each such pair of choices produces one distinct sample, so there are \(\binom{K}{k}\binom{N-K}{n-k}\) favorable samples. Dividing favorable samples by all samples gives the stated probability.

This counting argument also explains why the denominator is not \(\binom{N}{k}\): the sample contains \(n\) objects in total, not \(k\). The count \(k\) describes only how many of those \(n\) objects belong to the designated category.

Worked Calculations

Worked Example: Exactly Four Components in a Sample

A hypothetical batch contains 18 units, and 9 units contain a specified component. Six units are selected at random without replacement. Find the probability that exactly 4 selected units contain the component. There is no interest rate or mortality assumption; this is a finite-population sampling problem with \(N=18\), \(K=9\), \(n=6\), and target \(k=4\).

Method. Use the hypergeometric exact-count formula. To have exactly 4 units with the component, choose 4 of the 9 such units and 2 of the remaining 9 units: $$ P(X=4)=\frac{\binom{9}{4}\binom{9}{2}}{\binom{18}{6}}. $$

Evaluate the combinations: $$ \binom{9}{4}=\frac{9\cdot8\cdot7\cdot6}{4\cdot3\cdot2\cdot1}=126,\qquad \binom{9}{2}=\frac{9\cdot8}{2\cdot1}=36. $$

For the denominator, $$ \binom{18}{6}=\frac{18\cdot17\cdot16\cdot15\cdot14\cdot13}{6\cdot5\cdot4\cdot3\cdot2\cdot1}=18{,}564. $$ Thus the favorable sample count is \(126\cdot36=4{,}536\), and $$ P(X=4)=\frac{4{,}536}{18{,}564}=\frac{378}{1{,}547}\approx0.2443439. $$

Rounded to four decimal places, the probability is 0.2443. The fraction is less than 1, as a probability must be. This method avoids treating the draws as independent, which would incorrectly use a binomial probability.

Worked Example: Simplifying a Probability With Unequal Category Counts

A hypothetical archive contains 24 files, 7 of which are marked for review. Five files are selected at random without replacement. Find the probability that exactly 2 selected files are marked. There is no interest rate or mortality assumption; the hypergeometric parameters are \(N=24\), \(K=7\), \(n=5\), and \(k=2\).

Method. Count the ways to choose 2 of the 7 marked files and 3 of the \(24-7=17\) unmarked files. Divide by the number of all 5-file samples: $$ P(X=2)=\frac{\binom{7}{2}\binom{17}{3}}{\binom{24}{5}}. $$

The combinations are $$ \binom{7}{2}=\frac{7\cdot6}{2}=21,\qquad \binom{17}{3}=\frac{17\cdot16\cdot15}{3\cdot2\cdot1}=680. $$

For the total number of samples, $$ \binom{24}{5}=\frac{24\cdot23\cdot22\cdot21\cdot20}{5\cdot4\cdot3\cdot2\cdot1}=42{,}504. $$ The favorable count is \(21\cdot680=14{,}280\). Therefore, $$ P(X=2)=\frac{14{,}280}{42{,}504}=\frac{595}{1{,}771}\approx0.3359684. $$

Rounded to four decimal places, the answer is 0.3360. Dividing numerator and denominator by 24 gives the reduced fraction. Keeping the exact fraction until the final step avoids rounding error during simplification. This calculation also avoids using \(7/24\) as if it were the success probability on every draw; the selection is without replacement.

Worked Example: Evaluating Larger Combinations by Cancellation

A hypothetical shipment has 20 packages, 6 of which need an additional inspection. A random sample of 6 packages is selected without replacement. Find the probability that exactly 2 packages in the sample need the additional inspection. There is no interest rate or mortality assumption; use the hypergeometric model with \(N=20\), \(K=6\), \(n=6\), and \(k=2\).

Method. There must be 2 of the 6 packages needing inspection and 4 of the other 14 packages: $$ P(X=2)=\frac{\binom{6}{2}\binom{14}{4}}{\binom{20}{6}}. $$

Evaluate each combination, cancelling factorial terms before multiplying where convenient: $$ \binom{6}{2}=\frac{6\cdot5}{2\cdot1}=15, $$ $$ \binom{14}{4}=\frac{14\cdot13\cdot12\cdot11}{4\cdot3\cdot2\cdot1}=1{,}001, $$ and $$ \binom{20}{6}=\frac{20\cdot19\cdot18\cdot17\cdot16\cdot15}{6\cdot5\cdot4\cdot3\cdot2\cdot1}=38{,}760. $$

The number of favorable samples is \(15\cdot1{,}001=15{,}015\). Hence $$ P(X=2)=\frac{15{,}015}{38{,}760}=\frac{1{,}001}{2{,}584}\approx0.3873839. $$

Rounded to four decimal places, the probability is 0.3874. The answer is between 0 and 1, and the favorable count is smaller than the total count. The cancellation-based evaluation reduces the chance of an arithmetic error from unnecessarily large factorials. It also makes clear that the 4 packages not needing inspection are chosen from 14, not from 20.

Reliable Combination Arithmetic

For moderate combination values, writing out the factorial definition is usually enough. For larger values, cancel common factors before multiplying. For example, in \(\binom{14}{4}\), the factorial form reduces to a product of four descending terms in the numerator divided by \(4!\). This avoids calculating \(14!\) and then dividing two very large integers.

A sound calculation should keep exact integers or fractions until the final probability. Premature rounding can alter the last requested decimal place, particularly when several combinations are multiplied. After computing the probability, check that the numerator is positive, that it does not exceed the denominator, and that the target count is feasible. A result outside the interval from 0 to 1 signals an arithmetic or modeling error.

1
Translate the situation.
Record the population size \(N\), number of successes \(K\), sample size \(n\), and requested exact count \(k\). Confirm that sampling is without replacement and that each sample of size \(n\) is equally likely.
2
Build the favorable count.
Use \(\binom{K}{k}\) for selecting the successes and \(\binom{N-K}{n-k}\) for selecting the nonsuccesses.
3
Count every possible sample.
Use \(\binom{N}{n}\), because the sample has \(n\) objects in total.
4
Calculate, simplify, and check.
Evaluate the combinations carefully, retain exact values as long as possible, and round the probability only at the end.

Common Exam Traps

A frequent error is to substitute the initial success proportion \(K/N\) into a binomial formula. That formula assumes independent trials with the same success probability on every trial. In sampling without replacement, the remaining composition changes after each draw. For the 18-unit example, the incorrect binomial calculation would be $$ \binom{6}{4}\left(\frac{1}{2}\right)^4\left(\frac{1}{2}\right)^2 =15\left(\frac{1}{2}\right)^6 =\frac{15}{64} =0.234375, $$ which is not the correct hypergeometric probability \(0.2443\). The correction is to count fixed-size subsets, giving \(\binom{9}{4}\binom{9}{2}/\binom{18}{6}\).

  • Using the wrong number of nonsuccesses. If exactly \(k\) successes are in a sample of size \(n\), then there must be \(n-k\) nonsuccesses, chosen from \(N-K\).
  • Using the wrong denominator. The denominator counts all samples of size \(n\), so it is \(\binom{N}{n}\), not a combination based on \(k\).
  • Counting order as if it mattered. A sample is an unordered subset. Multiplying by possible draw orders after using combinations double-counts the same sample.
  • Ignoring feasibility. An exact count is impossible if the population does not contain enough successes or nonsuccesses to fill the requested sample composition.
  • Rounding combinations too early. Combination values are integers; compute them exactly and round only the final probability to the requested precision.
Key takeaway: For an exact hypergeometric probability, count the ways to choose exactly the required number from each category, then divide by all samples of the specified size. The numerator must account for both successes and nonsuccesses, and the denominator must match the total sample size.

Check Your Understanding

For each problem, identify the population and sample counts, apply the exact-count formula, and round the final probability to four decimal places.

  1. A tray contains 12 sensor cards, 5 of which have a calibration mark. Three cards are selected without replacement. Find the probability that exactly 2 have the mark. (Answer: 0.3182)
  2. A set of 15 application files contains 4 files requiring a second review. Four files are sampled without replacement. Find the probability that exactly 1 requires a second review. (Answer: 0.4835)
  3. A stockroom has 20 valves, 8 of which are from a designated production lot. Five are selected without replacement. Find the probability that exactly 3 are from that lot. (Answer: 0.2384)
  4. A collection of 16 digital records includes 6 records with a formatting flag. Five records are selected without replacement. Find the probability that none of the selected records has a flag. (Answer: 0.0577)
  5. A shipment contains 22 sealed containers, 9 of which carry a special label. Six are selected without replacement. Find the probability that exactly 4 carry the label. (Answer: 0.1317)
Clinical Biostats