Hypergeometric
Create a new Hypergeometric distribution
Hypergeometric X = Hypergeometric(K, N, n); Distribution properties:
Property
Type/Return type
Description
Example
//Example: Suppose you have a jar containing 15 marbles: 10 red marbles
//(successes) and 5 blue marbles (failures). You draw 5 marbles without
//replacement and want to find the probability of drawing exactly 3 red marbles
int K = 10; //4 successful items (red marbles)
int N = 15; //total population size
int n = 5; //sample size of 5
Hypergeometric X = Hypergeometric(K, N, n);
std::cout << X.P(3) << std::endl; //0.3996Hypergeometric X = Hypergeometric(5, 15, 2);
std::cout << X.P(-1) << std::endl; //Error: Number of successes in sample cannot be less than 0 or more than the sample size or more than the number of successes in population.Last updated