# Number of Bernoulli trials to first success, with changing $p$

[A version of this question was previously posted by another user, but the OP deleted rather than edit the question into a more suitable form for routine textbook work. I am reposting in the hope of attracting an answer that was outlined there,]

Suppose $X_1 \sim \text{Bernoulli}(p_1),... , X_n \sim \text{Bernoulli}(p_n)$.

If a realization of $X_1$ is a success, stop. Otherwise, get a realization of $X_2$. Continue on in this manner until a success is observed, cycling back around to success probability $p_1$ when necessary (i.e. if the first $n$ trials were all failures).

Let $Y$ be a random variable representing the number of trials until a success.

Can anyone offer guidance and hints toward finding the pmf of $Y$?

• (By way of showing how to post an attempt as well as a hint ) The obvious initial strategy is to start writing it term by term $P(Y=1) = p_1$ ; $P(Y=2) = \ldots$ The main issue would then be writing down a general term; – Glen_b Oct 14 '16 at 0:00

We all come in contact with a special case of this distribution when going Bernoulli $\rightarrow$ Geometric distribution.

The Bernoulli distribution is the realization of an event $X_k=1$ with $\Pr(X_k=1)=\theta$. The Geometric distribution $Y$ is the realization of $y-1$ non-events and $1$ event, all iid trials i.e

$$\Pr(Y= y)=\Pr(X_1=\ldots X_{y-1}=0\cap X_y=1)$$

This should be enough of a hint.

edit2: after @Glen_b's comment

In general, any positive random variable $Y$ and in particular the discrete ones (Poisson, Geometric, Rayleigh, Weibull) can be seen as a sequence of independent (but not identically) distributed Bernoulli trials, a sequence of non-events followed by an event. Set $\Pr(X_t=1)=\theta_t$ and see that

$$\Pr(Y=y)=\theta_y\prod_{t=1}^{y-1}(1-\theta_t)$$

Sidenote

To factor any positive distribution $T\in[0,\infty)$ we can write its survival function as $S(t)=1-F(t)=e^{-\Lambda(t)}$ where \begin{align} \Lambda(0)&=0\\ \Lambda(\infty)&=\infty\\ \frac{d}{dt}\Lambda(t)&=\lambda(t)\geq 0\\ \end{align}

And note that the probability of event within $s$ steps from $t$ is

\begin{align} F(t,s)&=Pr(T\leq t+s|T>t) \\ &=\frac{\Pr(T\in[t,t+s))}{Pr(T>t)}\\ &=\frac{S(t)-S(t+s)}{S(t)} \\ &= 1-e^{-(\Lambda(t+s)-\Lambda(t))}=1-e^{-R(t,s)} \end{align}

This is called the Conditional Excess Cumulative Distribution Function. In particular, using a steplength of $1$ we have $R(t,1)=d(t)$ and we may write \begin{align} \theta_t&=1-e^{-d(t)}\\ \Pr(T\in[y,y+1))&=\theta_y\prod_{t=1}^{y-1}(1-\theta_t)= e^{-d(y)}-e^{-d(y+1)} \end{align}

• (originally in main answer as tiny latex text) I said I would be answering this question using Cumulative Hazard Functions in a previous question but can't find a way to do it without explicitly revealing the answer. – ragulpr Oct 14 '16 at 0:36
• In particular I was hoping you'd define your $\theta$s from your earlier comment (e.g. something like "Let $\theta_t$ be the success probability at trial $t$, so $\theta_t = p_t$ for $i=1,2,\ldots,n$ and in general $\theta_t = p_{t\,\text{mod}\,n}$ for $t=1,2,...$"). Your notation choice makes the solution facile and readily generalizable to similar problems; a good choice of notation is very valuable and it would be worth making sure it appears. – Glen_b Oct 14 '16 at 0:46
• @Glen_b thanks for your insistence, I think your comment neatly wraps it up but I did try to incorporate what I wrote before. Also I could not keep myself from going to Cumulative-Hazard Land – ragulpr Oct 14 '16 at 1:36