Length of a bernoulli process to get a fixed amount of tails I have the following Bernoulli process:

*

*Initial state: H = 0, T = 0

*I launch a coin where probability of head is p.

*If I get head, then H = H + 1. If I get tails, then T = T + 1.

*I repeat the experiment until T = t_0.

Given that, I want to know how many times I have to keep this Bernoulli process going until getting $t_0$ tails (for example, $t_0 = 100$). Since $t_0$ is a constant and $n = H + t_0$, that is, I guess, the same as asking for the probability distribution of $H$ given $t_0$ tails.
The point is to generate a random number for $H$ from its probability distribution given $p$ and $t_0$ without actually running the iteration.

What you want is negative binomial distribution which

models the number of successes in a sequence of independent and identically distributed Bernoulli trials before a specified (non-random) number of failures (denoted $r$) occur.

In your case, $r=t_0$ and tails are the "failures".
