1

I want to take samples from this discrete probability distribution of $n$, which I think is defined as:

$$\Pr(n=i) = p^i (1-p)$$

where $p$ is the probability of success in each independent Bernoulli trial. I.e. the number of consecutive successful binomial trials before the first unsuccessful one (or vice versa).

If $n$ were finite then this would be easy because I could calculate $Pr(n=i)$ for all $n$ and then sample from it.

I'm assuming this is a well-known distribution with software tools and I just don't know it's name.

Bill
  • 144
  • I think I may have found the answer in one of the comments on this other question: Expected value of the number of flips until the first head

    It should be mentioned, the name of this distribution is "the geometric distribution." See here for a table of common distributions. – JMoravitz Mar 19 '15 at 3:46 (Thank you @JMoravitz)

    – Bill Dec 08 '21 at 18:40
  • 1
    In the general case, this is usually the negative binomial distribution. More specifically, consider needing to have 3 failures or r failures and stopping on the 3rd or rth failure. This would be a negative binomial distribution. In your case, r =1, and you're right, it becomes a geometric distribution * (1-p).
    https://en.wikipedia.org/wiki/Negative_binomial_distribution
    – nickalh May 15 '24 at 13:15

0 Answers0