hypergeometric distribution on r

The hypergeometric distribution in the R programming language is used to calculate the probability of a specific number of successes in a sequence of draws from a finite population without replacement. The function in R for the hypergeometric distribution is dhyper().

To use the hypergeometric distribution in R, you need to provide the following parameters: - x: The number of successes in the sample - m: The number of successes in the population - n: The number of draws - k: The size of the population

The probability mass function (PMF) of the hypergeometric distribution is given by the formula: [ P(X = x) = \frac{{\binom{m}{x} \binom{k-m}{n-x}}}{{\binom{k}{n}}} ] Where: - (\binom{m}{x}) is the number of ways to choose x successes out of m - (\binom{k-m}{n-x}) is the number of ways to choose n-x failures out of k-m - (\binom{k}{n}) is the number of ways to choose n items out of k

In R, you can calculate the probability of getting exactly x successes using the dhyper() function. For example:

# Calculate the probability of getting 2 successes in 5 draws from a population of 10 with 4 successes
dhyper(2, 4, 6, 5)

This will return the probability of getting exactly 2 successes in 5 draws from the specified population.