Analyzing the Setup
We are tossing a coin n times, where the probability of getting a Head is p and a Tail is 1−p. We seek the probability pn that no two heads appear consecutively.
For
n=1, the possible outcomes are
H and
T. Since neither contains
HH, the probability is:
p1=p+(1−p)=1
For
n=2, the outcomes are
HH,HT,TH,TT. The only forbidden sequence is
HH, which occurs with probability
p2. Thus, the probability of success is:
p2=1−p2
The Recurrence Logic
To find pn, we partition the valid sequences based on the first toss.
If the first toss is a Tail (probability
1−p), we are left with
n−1 tosses that must contain no consecutive heads. This contributes:
(1−p)pn−1
If the first toss is a Head (probability
p), the second toss must be a Tail (probability
1−p) to avoid
HH. We are then left with
n−2 tosses that must contain no consecutive heads. This contributes:
p(1−p)pn−2
Summing these mutually exclusive cases, we obtain the master recurrence relation:
pn=(1−p)pn−1+p(1−p)pn−2
The Algebraic Elegance
This is a second-order linear homogeneous recurrence relation. We assume a solution of the form
pn=xn, which leads to the characteristic equation:
x2−(1−p)x−p(1−p)=0
Let the roots of this quadratic equation be
α and
β. The general solution is expressed as:
pn=Aαn+Bβn
To determine the constants
A and
B, we apply our base cases
p1=1 and
p2=1−p2. This yields a system of linear equations:
Aα+Bβ=1
Aα2+Bβ2=1−p2
Solving this system, we find the constants:
A=αβ−α2p2+β−1
B=αβ−β2p2+α−1
By solving this system, you have successfully navigated the logic of constraints, the beauty of recurrence, and the power of algebraic substitution to determine the probability of avoiding consecutive heads.