The “rnbinom” Function in R
Package: Base R (no specific package required)
Purpose: Generates random numbers from a negative binomial distribution.
General Class: Random Number Generation
Required Argument(s):
n: The number of random values to generate.
size: The size parameter of the negative binomial distribution (number of successful trials).
prob: The probability of success on each trial.
Notable Optional Arguments:
None.
Example:
# Generate 100 random values from a negative binomial distribution
random_values <- rnbinom(n = 100, size = 10, prob = 0.3)
print(random_values)In this example, the rnbinom function generates 100 random values from a negative binomial distribution with a size parameter of 10 and a probability of success of 0.3. The generated values are then printed to the console.