The HYPGEOMDIST function in Google Sheets calculates the probability of a specific number of successes in a sequence of draws from a finite population without replacement. Unlike the binomial distribution, where the probability of success remains constant (sampling with replacement), the hypergeometric distribution accounts for the fact that each draw changes the composition of the remaining population. This is essential for quality control, ecology studies, and card game mathematics where once an item is picked, it cannot be picked again.
What You'll Need
- A Google account with access to Google Sheets.
- A dataset or a specific scenario involving a finite population (e.g., a deck of cards, a batch of manufactured parts, or a group of employees).
- The four specific variables required by the formula: sample size, number of successes in the sample, number of successes in the population, and the total population size.
Step-by-Step
- Define Your Variables: Before typing the formula, identify your four key numbers. To avoid errors, it is best to place these in separate cells (e.g., A2 through A5) rather than typing them directly into the formula.
- Sample Size (n): The number of items you are drawing from the population.
- Successes in Sample (x): The exact number of successful outcomes you want to find the probability for.
- Successes in Population (M): The total number of items in the entire population that are considered a "success."
- Population Size (N): The total number of all items in the population.
- Select the Target Cell: Click on the cell where you want the probability result to appear.
- Enter the Function: Type
=HYPGEOMDIST(into the cell. - Input the Arguments: Enter the values in the exact order required by Google Sheets. The syntax is
=HYPGEOMDIST(sample_size, successes_in_sample, successes_in_population, population_size).- If you placed your variables in cells A2 through A5, your formula would look like:
=HYPGEOMDIST(A2, A3, A4, A5).
- If you placed your variables in cells A2 through A5, your formula would look like:
- Close the Parenthesis and Press Enter: Complete the formula with a closing parenthesis
)and hit Enter. The result will be a decimal between 0 and 1, representing the probability. - Format as Percentage: To make the result easier to read, select the cell and click the % icon in the toolbar to convert the decimal to a percentage.
Worked Example: Quality Control
Imagine you have a box of 100 computer chips (Population Size = 100). You know that 10 of these chips are defective (Successes in Population = 10). You randomly pick 5 chips to test (Sample Size = 5). You want to know the probability that exactly 2 of those 5 chips are defective (Successes in Sample = 2).
Your setup in Google Sheets would be:
- Cell A2: 5 (Sample Size)
- Cell A3: 2 (Successes in Sample)
- Cell A4: 10 (Successes in Population)
- Cell A5: 100 (Population Size)
=HYPGEOMDIST(A2, A3, A4, A5). This will return the probability of picking exactly 2 defective chips out of 5 from a pool of 100 containing 10 defectives.
Common Mistakes
Swapping the Population and Sample: One of the most frequent errors is reversing the order of the arguments. Users often put the total population size first. Remember that Google Sheets expects the sample size first and the total population last. If you swap these, the function will likely return a #NUM! error because the sample size cannot be larger than the population.
Confusing Binomial with Hypergeometric: Users often use BINOMDIST when they should use HYPGEOMDIST. If you are drawing a card from a deck and putting it back before drawing again, use Binomial. If you are drawing a card and keeping it out of the deck, you must use Hypergeometric. Using the wrong function will lead to slightly inaccurate probabilities, especially in small populations.
Using Non-Integers: The hypergeometric distribution deals with countable items (people, parts, cards). If you enter decimals (e.g., 2.5 successes), the function will return an error or an unexpected result because you cannot have half of a success in a discrete sample.
Incorrect Success Logic: Ensure that the "successes in sample" is not greater than the "successes in population." For example, you cannot find the probability of drawing 5 red marbles from a jar that only contains 3 red marbles. This will result in a probability of 0 or an error.
Tips
Calculating "At Least" or "At Most": The HYPGEOMDIST function calculates the probability of an exact number. If you need the probability of getting at least 2 successes, you must sum the probabilities of getting 2, 3, 4, and 5 successes. You can do this by creating a small table with the HYPGEOMDIST function for each possible value of x and then using the SUM function to add them together.
Dynamic Ranges: Instead of hard-coding numbers, always use cell references. This allows you to change your population size or sample size and see the probability update instantly without having to rewrite the formula.
Data Validation: If you are building a tool for others to use, use Data Validation (Data > Data validation) on your input cells to ensure that users only enter positive integers and that the sample size does not exceed the population size.
Troubleshooting
#NUM! Error: This is the most common error. It occurs when one of the arguments is invalid. Check the following:
- Is the sample size larger than the population size? (It shouldn't be).
- Are there more successes in the sample than there are in the total population? (This is impossible).
- Are any of your numbers negative? (All inputs must be 0 or positive).
#VALUE! Error: This typically happens if one of the cells you referenced contains text instead of a number. Check your input cells for hidden spaces or characters that might be treating the number as a string.
The result is 0: If the result is 0, it doesn't necessarily mean the formula is broken. It may mean that the scenario you are testing is statistically impossible or so unlikely that the result is smaller than Google Sheets can display in standard decimal format. Double-check your "successes in population" value to ensure it is high enough to support the "successes in sample" you are requesting.
Incorrect Probability: If the number seems "off," verify that you are truly sampling without replacement. If the items are being replaced, the HYPGEOMDIST function is the wrong tool; switch to BINOMDIST.
Frequently Asked Questions
What is the difference between HYPGEOMDIST and BINOMDIST?
The primary difference is replacement. BINOMDIST assumes that the probability of success is the same for every trial (sampling with replacement). HYPGEOMDIST assumes the probability changes as items are removed from the pool (sampling without replacement).
Can I use this for very large populations?
Yes, but as the population size becomes extremely large relative to the sample size, the results of HYPGEOMDIST and BINOMDIST become nearly identical. In those cases, the binomial distribution is often simpler to calculate.
Does the order of the items drawn matter?
No. The hypergeometric distribution calculates the probability of a specific number of successes regardless of the order in which they were drawn from the population.
What happens if I set the successes in sample to 0?
The function will calculate the probability that none of the items in your sample are successes. This is a valid calculation and is often used to find the probability of a "perfect" sample with no defects.
Is there a version of this function for cumulative probability?
Unlike BINOMDIST, which has a cumulative boolean argument, HYPGEOMDIST in Google Sheets only provides the probability mass function (the exact probability). To get a cumulative probability, you must manually sum the results for all values from 0 up to your target number.