Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let random variable $X$ be defined as the number of independent Bernoulli(p) trials required until we observe either two successes or two failures in a row. Find $P(X=n)$ for $n=2,3,4, \ldots$ Then find the expectation and variance of $X$.

Okay so since there has to be two successes or failures in a row, the trials have to alternate $SFSFSF...$ or $FSFSFS...$ until it comes upon two successes or two failures. I initially tried using the Negative Binomial Distribution here but I remembered that it doesn't take order into account so that wouldn't work. Then I tried breaking it up into if $n$ is odd vs. if $n$ is even but but I didn't really know where to go from there...

share|cite|improve this question

You can try a simple bookkeeping here like this. If $p$ is the probability of success, than, obviously, you get $$ P(X=2)=p^2+(1-p)^2=1-2p+2p^2, $$ because either you have two successes or two failures, and these two events are disjoint. Next, $$ P(X=3)=(1-p)p^2+p(1-p)^2=(1-p)p. $$ Two more: $$ P(X=4)=p(1-p)p^2+(1-p)p(1-p)^2=(1-p)p(1-2p+2p^2). $$ $$ P(X=5)=(1-p)p(1-p)p^2+p(1-p)p(1-p)^2=(1-p)^2p^2. $$ Do you see a pattern here? If not, try a couple more values for $n$. Finally, you get $$ P(X=2k)=(p(1-p))^{k-1}(1-2p+2p^2),\quad k=1,2,\ldots $$ $$ P(X=2k+1)=(p(1-p))^{k},\quad k=1,2,\ldots $$ The sanity check shows that $\sum_k [P(X=2k)+P(X=2k+1)]=1$ as it should be.

Using the found distribution it is possible to find $E[X]$ and Var$[X]$ if you know how to find sums of the form $$ \sum_k kp^k,\quad \sum_k k^2p^k. $$

share|cite|improve this answer

Hint: This will depend upon the probability of success, so name it $X(p)$, where $p$ is the probability of success on one trial. $X(p)=X(1-p)$ do you see why? We can either start with a success or a failure. If we let $Y(p)$ be the number of additional trials required for two successes or two failures if we have started with a success and $Z(p)$ be the number of additional trials required for two successes or two failures if we have started with a failure, then $X(p)=2(p^2+(1-p)^2)+(1-p)pY(p)+p(1-p)Z(p), Y(p)=p+(1-p)(1+Z(p)), Z(p)=(1-p)+p(1+Y(p))$. For $X$, we can either have the first two be the same, or have them different. Then for $Y$ and $Z$, we can either have the first one match what we came in with or not. Three equations in three unknowns.

share|cite|improve this answer
I dont really understand where the Y and Z equations are coming from, I get that p and (1-p) are the probability of success and failure respectively but wouldnt it make more sense to work from the back to front i.e. see if the last two trials are the same then work backwards from there? – donkeykong15 Apr 23 '12 at 6:21
@donkeykong15: you can do it that way and Artem did. My approach was to find disjoint conditions that lead to the end. Either you start with two successes or two failures, or you start with one of each and keep going. If you keep going, you care what the previous result is, because that is the one that terminates now. The equation for $Y$ comes from the fact that you either succeed and are done, or fail and now you need $Z$ trials. – Ross Millikan Apr 23 '12 at 13:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.