Chapter 11: Problem 2
Give a method for simulating a negative binomial random variable.
Short Answer
Expert verified
To simulate a negative binomial random variable, follow these steps:
1. Define the parameters: probability of success \(p\) (0 < p ≤ 1) and target number of successes \(r\). Initialize a counter for the number of failures \(F\) and successes \(S\) to 0.
2. Generate a random number \(U\) uniformly distributed between 0 and 1, using a built-in function (e.g., `random.random()` in Python).
3. Compare \(U\) to \(p\). If \(U ≤ p\), increment successes (S = S + 1). If \(U > p\), increment failures (F = F + 1).
4. Check if the target number of successes \(r\) has been reached. If yes, the negative binomial random variable is equal to the number of failures \(F\).
5. If the target number of successes is not reached, go back to Step 2 and repeat until the target number of successes is achieved.
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.