{
  "id": "hypergeometric",
  "version": "4e2396c594c4",
  "status": "published",
  "name": "Hypergeometric Distribution Calculator",
  "question": "Hypergeometric: how likely is k?",
  "summary": "Computes exact hypergeometric probabilities P(X = k), P(X < k), P(X ≤ k), P(X > k) and P(X ≥ k) for n draws without replacement from N items with K successes, with the mean and standard deviation.",
  "category": "statistics",
  "subcategory": "distributions",
  "url": "https://www.acalculator.org/statistics/hypergeometric-calculator",
  "markdown": "https://www.acalculator.org/statistics/hypergeometric-calculator.md",
  "kind": "function",
  "method": "P(X = k) = C(K, k) × C(N − K, n − k) ÷ C(N, n); P(X ≤ k) = Σ P(X = j) for j ≤ k; mean = nK ÷ N; variance = n (K ÷ N)((N − K) ÷ N)((N − n) ÷ (N − 1)).",
  "assumptions": [
    "The n items are drawn at random without putting any back, so every set of n items is equally likely.",
    "Each item is either a success or not, and the population size N and successes K are known."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "N": {
        "title": "Population size (N)",
        "description": "How many items there are in all, from 1 to 1,000.",
        "type": "integer",
        "minimum": 1,
        "maximum": 1000
      },
      "K": {
        "title": "Successes in the population (K)",
        "description": "How many of the N items count as a success, from 0 to N.",
        "type": "integer",
        "minimum": 0,
        "maximum": 1000
      },
      "n": {
        "title": "Sample size (n)",
        "description": "How many items are drawn without putting any back, from 1 to N.",
        "type": "integer",
        "minimum": 1,
        "maximum": 1000
      },
      "k": {
        "title": "Successes in the sample (k)",
        "description": "The number of successes to find the probability of, from 0 to n.",
        "type": "integer",
        "minimum": 0,
        "maximum": 1000
      }
    }
  },
  "outputs": {
    "exactly": {
      "label": "P(X = k)",
      "description": "The probability of exactly k successes.",
      "format": "number"
    },
    "below": {
      "label": "P(X < k)",
      "description": "The probability of fewer than k successes.",
      "format": "number"
    },
    "atMost": {
      "label": "P(X ≤ k)",
      "description": "The probability of k or fewer successes.",
      "format": "number"
    },
    "above": {
      "label": "P(X > k)",
      "description": "The probability of more than k successes.",
      "format": "number"
    },
    "atLeast": {
      "label": "P(X ≥ k)",
      "description": "The probability of k or more successes.",
      "format": "number"
    },
    "mean": {
      "label": "Mean (nK ÷ N)",
      "description": "The expected number of successes in the sample.",
      "format": "number"
    },
    "variance": {
      "label": "Variance",
      "description": "n × (K ÷ N) × ((N − K) ÷ N) × ((N − n) ÷ (N − 1)); 0 when N = 1.",
      "format": "number"
    },
    "sd": {
      "label": "Standard deviation",
      "description": "The square root of the variance.",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "N": 52,
      "K": 13,
      "n": 5,
      "k": 2
    },
    "outputs": {
      "exactly": 0.2742797118847539,
      "below": 0.632953181272509,
      "atMost": 0.9072328931572629,
      "above": 0.09276710684273709,
      "atLeast": 0.367046818727491,
      "mean": 1.25,
      "variance": 0.8639705882352942,
      "sd": 0.9295001819447343
    },
    "text": "Drawing 5 from 52 with 13 successes, the chance of exactly 2 successes is 0.27428, and of at least 2 is 0.367047."
  },
  "examples": [
    {
      "given": {
        "N": 52,
        "K": 13,
        "n": 5,
        "k": 2
      },
      "expect": {
        "exactly": 0.2742797118847539,
        "mean": 1.25
      },
      "source": "hand calculation in content.mdx: C(13, 2) × C(39, 3) ÷ C(52, 5) = 78 × 9,139 ÷ 2,598,960 = 9,139 ÷ 33,320 = 0.27428; NIST/SEMATECH e-Handbook of Statistical Methods, glossary: hypergeometric distribution (sampling without replacement; population N, sample n, defectives D), https://www.itl.nist.gov/div898/handbook/glossary.htm"
    },
    {
      "given": {
        "N": 49,
        "K": 6,
        "n": 6,
        "k": 6
      },
      "expect": {
        "exactly": 7.151123842018516e-8,
        "atMost": 1,
        "below": 0.9999999284887616
      },
      "source": "hand calculation in content.mdx: 1 ÷ C(49, 6) = 1 ÷ 13,983,816; NIST/SEMATECH e-Handbook of Statistical Methods, glossary: hypergeometric distribution (sampling without replacement; population N, sample n, defectives D), https://www.itl.nist.gov/div898/handbook/glossary.htm"
    },
    {
      "given": {
        "N": 100,
        "K": 10,
        "n": 10,
        "k": 0
      },
      "expect": {
        "exactly": 0.33047621108672515,
        "atLeast": 1,
        "above": 0.6695237889132748,
        "mean": 1,
        "variance": 0.8181818181818182
      },
      "source": "hand calculation in content.mdx: C(90, 10) ÷ C(100, 10) = 0.330476; variance 10 × 0.1 × 0.9 × 90/99 = 0.8182; NIST/SEMATECH e-Handbook of Statistical Methods, glossary: hypergeometric distribution (sampling without replacement; population N, sample n, defectives D), https://www.itl.nist.gov/div898/handbook/glossary.htm",
      "tolerance": 1e-12
    },
    {
      "given": {
        "N": 10,
        "K": 3,
        "n": 4,
        "k": 3
      },
      "expect": {
        "exactly": 0.03333333333333333,
        "atLeast": 0.03333333333333333,
        "below": 0.9666666666666667
      },
      "source": "hand calculation in content.mdx: C(3, 3) × C(7, 1) ÷ C(10, 4) = 7 ÷ 210; NIST/SEMATECH e-Handbook of Statistical Methods, glossary: hypergeometric distribution (sampling without replacement; population N, sample n, defectives D), https://www.itl.nist.gov/div898/handbook/glossary.htm"
    }
  ],
  "sources": [
    "NIST/SEMATECH e-Handbook of Statistical Methods, Glossary: hypergeometric distribution (count of defectives when sampling without replacement; parameters N, n and D, all whole numbers). https://www.itl.nist.gov/div898/handbook/glossary.htm (retrieved 2026-10-01)",
    "NIST/SEMATECH e-Handbook of Statistical Methods, §7.3.3 How can we determine whether two processes produce the same proportion of defectives? (the hypergeometric distribution gives the exact probability of a 2 × 2 table with fixed margins). https://www.itl.nist.gov/div898/handbook/prc/section3/prc33.htm (retrieved 2026-10-01)"
  ],
  "related": [
    "binomial-distribution",
    "combination",
    "probability"
  ],
  "changelog": []
}
