There are 13 ways to toss a fair coin 4 times so that tails never comes up three times in a row.
How many ways are there to toss a fair coin 12 times so that tails never comes up three times in a row?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Hmm, is it a coincidence that the answer is just X n − 1 ? Seems like this could be simplified with the right argument. Maybe instead of using the "building blocks," you could note that the same recurrence is satisfied by the number of sequences with no three tails, by the same inductive argument about what they start with.
Log in to reply
X n + 1 , not X n − 1 , I think, since X 4 = 7 is the number of TTT-free sequences of length 3 . Your argument is much better, though. The recurrence relation, of course, works for TTT-free sequences of length n ; we just need to change the initial conditions.
We could use principle of inclusion and exclusion.
My method used the recursive relation a n=2a (n-1)-2^(n-4) where a 3=7. Can someone explain where I went wrong. My method gave me 1280.
Log in to reply
I think you want the recurrence relation a n = 2 a n − 1 − a n − 4 (not 2 n − 4 ). This works, with a 0 = 1 , a 1 = 2 , a 2 = 4 , a 3 = 7 .
To get a T T T -free sequence of length n , start with a T T T -free sequence of length n − 1 . You can then add either H or T to the end, except when the length n − 1 sequence ends T T . Thus a n = 2 a n − 1 − b n − 1 where b n − 1 is the number of T T T -free sequences of length n − 1 which end T T . But all such sequences are obtained from a T T T -free sequence of length n − 4 , followed by H T T , and hence b n − 1 = a n − 4 . Thus we obtain the recurrence relation at the start.
Log in to reply
@Mark Hennings – Thanks this makes sense. I'm glad I was on the right track.
Using Patrick's argument shouldn't we split up the sequences into those starting with H , T H and T T H instead of T , H T and H H T ?
Also is there any way to find a closed form expression of this recurrence relation ? (I had to do it manually)
Log in to reply
I believe you are right about your first question.
For the second question, the answer is yes, but it's fairly ugly and requires some complex numbers, namely two of the three roots of the polynomial x 3 − x 2 − x − 1 . See the tribonacci sequence wiki for some details. There are formulas for large n that are not in the wiki, involving the nearest integer to powers of the tribonacci constant times another constant.
Anyway, in practice, doing it manually will probably be fastest!
Oops. Corrected.
As Patrick says, there is no nice closed formula. There are general techniques for solving recurrence relations like this. Recurrence relations can be regarded as discrete versions of differential equations, and many of the techniques that can be used to solve some types of differential equation yield analogous technqiues.
If we consider the recurrence relation X n + k + a k − 1 X n + k − 1 + a k − 2 X n + k − 2 + ⋯ + a 1 X n + 1 + a 0 X n = 0 (where a k − 1 , … , a 0 are constants) then we note that X n = λ n will be a solution provided that λ n + k + a k − 1 λ n + k − 1 + ⋯ + a 1 λ n + 1 + a 0 λ n = 0 for all n , and hence provided that λ k + a k − 1 λ k − 1 + ⋯ + a 1 λ + a 0 = 0 . ( ⋆ ) In general there will be k distinct roots λ 1 , λ 2 , … , λ k of this polynomial equation, yielding a general solution X n = A 1 λ 1 n + A 2 λ 2 n + ⋯ + A k λ k n of the recurrence relation, for arbitrary constants A 1 , … , A k . (You should recognise this as being like solving homogeneous differential equations with constant coefficients.)
If λ is a double root of ( ⋆ ) , its contribution to the solution becomes ( A + B n ) λ n . If λ is a triple root of ( ⋆ ) , its contribution becomes ( A + B n + C n 2 ) λ n . Similarly for higher levels of multiplicity. (Again, the analogy with differential equations is clear.)
If the recurrence relation is nonhomogeneous (so ( ⋆ ) ends with " = s o m e t h i n g " instead of just 0 ), find a particular integral, and add the general solution of the homogeneous equation. (Analogous techniques to those used to find particular integrals for differential equations will work here as well)
However, since the recurrence relation of this problem yields the moderately unpleasant (i.e., without elegant factors) cubic X 3 − X 2 − X − 1 = 0 ,. there is no particular gain to solving the recurrence relation exactly when we are only interested in the first few terms.
I have a direct solution (without considering cases of negation).
Note that the ways of tossing and of H and T have a bijection with each other.
Let t 2 n , t 1 n , t 0 n represent the allowable sequences ending with 2,1 and 0 consecutive tails respectively.
We have:
t 2 n = t 1 n − 1 ...(i)
t 1 n = t 0 n − 1 ...(ii)
The above two results can be shown by considering that we can append a T to the end of the n − 1 length chain to create an n length chain with one more consecutive T at the end.
Now let W n denote the total number of acceptable sequences.
Now, we have:
(By appending an H to the end of any acceptable sequence and removing H from end of any (acceptable) sequence ending with H ... bijection can be proved)
Also (obviously):
W n = t 0 n + t 1 n + t 2 n
Thus, we can show:
W n = W n − 1 + W n − 2 + W n − 3 ...by (i), (ii), (iii)
Problem Loading...
Note Loading...
Set Loading...
Let X n be the number of sequences of length n that can be built from the sequence elements H , T H and T T H . Then X 0 = 1 , X 1 = 1 , X 2 = 2 and X n = X n − 1 + X n − 2 + X n − 3 n ≥ 3 , counting the sequences by considering which sequence element is used first. Thus the terms X n can be determined inductively.
For any N ≥ 3 and any 3 ≤ n ≤ N , let Y N , n be the number of sequences of length N which do contain the subsequence T T T , and for which the subsequence T T T first occurs at positions n − 2 , n − 1 , n . The first n − 3 terms of such a sequence must be built up from the elements H , T H and T T H , since T T T cannot occur within the sequence, and the ( n − 3 ) rd term must be H , in order to ensure that T T T occurs for the first time in positions n − 2 , n − 1 , n . The last N − n terms of such a sequence can be chosen freely. Thus Y N , n = X n − 3 × 2 N − n 3 ≤ n ≤ N , Since the number of sequences containing the subsequence T T T is the sum of Y N , n for 3 ≤ n ≤ N , it follows that 2 N − n = 3 ∑ N Y N , n = 2 N − n = 3 ∑ N 2 N − n X n − 3 is the number of sequences of length N which do not contain the subsequence T T T . For N = 4 this gives the answer 1 3 . For N = 1 2 this gives the answer 1 7 0 5 .