The “rhyper” Function in R
Package: Base R (no specific package required)
Purpose: Generates random numbers from a hypergeometric distribution.
General Class: Random Number Generation
Required Argument(s):
nn: The number of random values to generate.
m: The number of white balls in the urn.
n: The number of black balls in the urn.
k: The number of balls drawn from the urn.
Notable Optional Arguments:
None.
Example:
# Generate 100 random values from a hypergeometric distribution
random_values <- rhyper(nn = 100, m = 20, n = 30, k = 10)
print(random_values)The rhyper function generates 100 random values from a hypergeometric distribution. The urn has 20 white balls and 30 black balls, and a sample of size 10 is drawn from the urn. The generated values are then printed to the console.