Probability without replacement

Hypergeometric Distribution Calculator

Calculate exact and cumulative probabilities when a sample is drawn from a finite population without replacement.

Population and sample

Enter the four count values

P(X)
Probability summary

Calculated outcomes

The probabilities will appear here

Counts must describe a possible sample from the population.

A finite population containing successes and other items with a smaller sample drawn without replacement
The model tracks successes in a fixed-size sample drawn from a finite population.

What Is a Hypergeometric Probability?

The Hypergeometric Distribution Calculator finds the chance of drawing a specified number of items with a chosen feature from a finite group without replacement. You supply the population size, population successes, sample size and desired sample successes. It reports exactly k, k or more, k or fewer and zero-success probabilities.

A success is simply the category you are counting, such as marked tokens or defective parts. It does not have to mean a desirable outcome. The model assumes every sample of the stated size is equally likely. Counts alone cannot verify that your real selection process is random.

How to Use the Hypergeometric Calculator

  1. Enter Population size (N), the total number of available items. This implementation accepts whole numbers from 1 to 170.
  2. Enter Successes in population (K), the number of items with the feature of interest, from 0 through N.
  3. Enter Sample size (n), the number drawn without replacement, from 0 through N.
  4. Enter Successes in sample (k), the target count. It must be possible given both the available successes and the available non-successes.
  5. Select Calculate probabilities. Read exactly k, k or more, k or fewer and zero-success results as percentages. Both cumulative results include k itself.

The form rejects an impossible requested k rather than returning an exact probability of zero for that entry. It can still show a zero probability in a different result card, such as Zero successes when the sample must contain a success. The upper population limit is a software limit, not a limit of the mathematical distribution.

Hypergeometric Probability Formulas

P(X = k) = C(K,k) × C(N − K,n − k) ÷ C(N,n)

L = max(0,n − (N − K)); U = min(K,n)

P(X ≥ k) = sum of P(X = i) for i from k through U

P(X ≤ k) = sum of P(X = i) for i from L through k

C(a,b), read “a choose b,” counts unordered selections. The numerator counts samples with k feature items and n−k other items; the denominator counts all size-n samples. L and U are the smallest and largest possible success counts.

SciPy’s hypergeometric reference documents the probability formula and valid support. R’s distribution reference describes probability mass and cumulative calculations. Their parameter letters differ, so compare the meanings rather than copying letters blindly.

The calculator multiplies each probability by 100 and rounds to six decimal places. The interface can display fewer decimal places. It does not return mean, variance, odds or a hypothesis-test p-value as separate results.

Population, Sample and Probability Results

Population size, N
Total available items, including both categories; an integer from 1 to 170 here.
Population successes, K
Items with the feature of interest, from 0 to N. This is a count, not a percentage.
Sample size, n
Number of items drawn without putting them back, from 0 to N.
Sample successes, k
Requested feature count in the sample. It must lie between the feasible limits L and U.
Exactly k
P(X=k), repeated in the featured result and Exactly k card. It concerns one specific count.
k or more
P(X≥k), including exactly k and all larger possible counts.
k or fewer
P(X≤k), including exactly k and all smaller possible counts.
Zero successes
P(X=0) for the same population and sample size. It is calculated separately from the requested k.

Hypergeometric Distribution Example

Illustrative example. A bag contains 24 tokens, seven of them marked. Draw five without replacement and ask for exactly two marked tokens: N=24, K=7, n=5 and k=2.

There are C(7,2)=21 ways to choose the marked pair, C(17,3)=680 ways to choose the three unmarked tokens and C(24,5)=42,504 possible five-token samples. The exact probability is 21 × 680 ÷ 42,504 = 85/253 ≈ 33.596838%.

For the same inputs, k or more is 46.245059%, k or fewer is 87.351779% and zero successes is 14.558630%. The interface may omit a trailing zero. These four cards describe different events rather than four mutually exclusive categories.

Calculation check. Independent integer combinations and exact-fraction sums agree with the calculator results. The example assumes uniformly random selection of five distinct tokens.

Example comparison. Review the inputs and results together using the assumptions in the caption.

Population 24, seven target items, sample of five without replacement
Target items in sampleExact probability
014.558630%
139.196311%
233.596838%
311.198946%

Exactly, At Least and At Most

Choose the event before reading the percentage. For a population of 24 containing seven target items and a sample of five, X counts the target items in the selected sample. At least and at most both include the entered count.

Events when the requested count is two
ResultEventCounts included
Exactly twoX = 22
Two or moreX ≥ 22, 3, 4, 5
Two or lessX ≤ 20, 1, 2
ZeroX = 00

The two cumulative events overlap at X = 2. Their probabilities therefore add to 100% plus the exactly-two probability before display rounding. They are not complementary events. The complement of “at least two” is “at most one.”

The possible target count runs from max(0, n − (N − K)) to min(K, n). This page rejects an entered count outside that interval. It does not show a zero exact probability for an impossible requested count, although its separate zero-target result can be zero for a valid request.

How to Interpret the Probability Results

Choose the event that matches the question. “Exactly two” differs from “at least two” and “at most two.” The cumulative cards overlap at exactly k, so they are not complements of each other.

Before rounding, P(X≥k)+P(X≤k)=1+P(X=k), because exactly k appears in both totals. For “more than k,” subtract the exact probability from k or more. For “fewer than k,” subtract it from k or fewer. This subtraction is an additional interpretation step rather than a separate result card.

Without replacement, the remaining composition changes after each draw. A simple independent-trial product or fixed-probability binomial model generally describes a different setup. When selection is biased or probabilities differ by item, the supplied counts may not justify the hypergeometric model.

A percentage is the modeled chance before sampling, not a guarantee of a particular sample. The calculator does not estimate the population’s success count, infer a sampling design or identify defects from observations.

Common Hypergeometric Calculation Mistakes

  • Entering a success percentage instead of the population success count K.
  • Swapping the population size with the sample size.
  • Using a replacement-sampling or independent-trial setup without checking the model.
  • Requesting more successes or non-successes than exist in the population.
  • Reading “k or more” as strictly more than k.
  • Treating the two inclusive cumulative cards as complementary probabilities.
  • Calling the zero-success probability the complement of exactly k for an arbitrary k.

Hypergeometric Probability Questions

When should I use a hypergeometric probability model?

Use it for a uniformly random fixed-size sample drawn without replacement from a finite population with known counts in two categories. Check that the selection process matches those assumptions.

What do N, K, n and k mean?

N is total population size, K is population successes, n is sample size and k is the success count requested in that sample. All four inputs are counts rather than percentages.

Does “k or more” include exactly k?

Yes. It sums probabilities for k and every larger possible count. Likewise, “k or fewer” includes k and all smaller possible counts.

Why do the two cumulative probabilities sum to more than 100%?

They overlap at exactly k. Before rounding, their sum is 100% plus the exactly-k probability; they are not complementary events.

Why does an impossible requested outcome produce an error?

This form requires k to be feasible given both categories and the sample size. The mathematical probability outside the support is zero, but the input-validation contract rejects that requested count.

Can I enter a sample size of zero?

Yes, with k=0 and otherwise valid population counts. The empty sample has zero successes with certainty, so the exactly-zero and inclusive cumulative results are 100%.

How is this different from a binomial model?

This model accounts for a finite population drawn without replacement. A binomial model uses independent trials with the same success probability; it can describe a different experiment or sometimes an approximation under suitable conditions.

Why is population size limited to 170?

That is the current implementation’s accepted range. It is not a mathematical maximum for the hypergeometric distribution, and the form does not provide a larger-population mode.

Sources and References