Evaluates the hypergeometric probability density function.

View versions (2)

Interface

#include <codecogs/statistics/distributions/discrete/hypergeometric/pdf.h>

using namespace Statistics::Distributions::Discrete::Hypergeometric;

This function evaluates the hypergeometric probability density function.

$$P(x) = \frac{\left ( \begin{array}{c}a\\x \end{array} \right ) \left ( \begin{array}{c}b\\n-x \end{array} \right )}{\left ( \begin{array}{c}a+b\\n \end{array} \right )}$$
(1)

Example 1

#include <iostream>
#include <codecogs/statistics/distributions/discrete/hypergeometric/pdf.h>

int main()
{
  std::cout << "hypergeometric PDF (5, 10, 20, 8) = ";
  std::cout << Statistics::Distributions::Discrete::Hypergeometric::PDF(5, 10, 20, 8) << std::endl;
  return 0;
}

Output:

hypergeometric PDF (5, 10, 20, 8) = 0.0490832

Parameters

x
the number of successes drawn, 0 <= x <= min(a,n)
a
the number of success items in the population
b
the number of failure items in the population
n
the number of items drawn (the sample size), n <= a+b
GPL Licence — free for non commercial use. See Licence details.

Interactive Calculator

x
a
b
n
Result