2
u/uzrfsh Preparing for GRE Jan 01 '21 edited Jan 01 '21
Your question is a bit ambiguous. But if I were to make the assumption that what you are asking for is exactly two heads in a row instead of at least two heads in a row then the probability will be 20/64 or 0.3125.
That's 20 possibilities for getting exactly 2 heads in a row versus 64 permutations for the 6 coin flips.
1
0
u/sibarz Jan 01 '21
I'm getting 5/64 por 2 heads in a row. 64 different outcomes, there are only 5 ways to get 2 heads in a row.
3
u/uzrfsh Preparing for GRE Jan 01 '21
I am not sure how you'd get 5 possibilities alone. Remember what we are looking for is to get two heads in a row, and only one such pair (exactly two heads in a row). That doesn't mean you can't have any more heads elsewhere. I wrote some code to get all the possibilities of exactly two heads in a row. Here's them if it helps:
HHTHTH, HHTHTT, HHTTHT, HHTTTH, HHTTTT, HTHHTH, HTHHTT, HTHTHH, HTTHHT, HTTTHH, THHTHT, THHTTH, THHTTT, THTHHT, THTTHH, TTHHTH, TTHHTT, TTHTHH, TTTHHT, TTTTHHThat's twenty possibilities.
2
u/sibarz Jan 01 '21
You are totally right, I was just considering cases where there were only 2 heads in the 6 coins flips.
3
u/LSAT-Hunter Jan 02 '21 edited Jan 02 '21
I assume you are asking for the probability that an instance of (at least) 2 consecutive heads appears at least once in the sequence of 6 coin tosses. In other words, HHHTTH and HHTTHH would both satisfy the condition of having 2 heads in a row.
Since the number of coin tosses, n=6, is low, we can just manually count how many sequences of coin flips satisfy the condition by splitting into cases.
Case 0: There are exactly 0 heads. No such sequences satisfy the condition.
Case 1: There is exactly 1 head. No such sequences satisfy the condition.
Case 2: There are exactly 2 heads. Then the 2 heads must be consecutive. The pair can occupy the first slot (HHTTTT) through the fifth slot (TTTTHH), so there are 5 sequences that satisfy the condition.
Case 3: There are exactly 3 heads. There are 6C3 = 20 total sequences having exactly 3 heads (and thus exactly 3 tails). How many of them do NOT satisfy the condition? Well to NOT satisfy the condition, the sequence must look like _ T _ T _ T _ , with the 3 heads occupying 3 out of the 4 slots, so there are 4C3 = 4 such sequences that do NOT satisfy the condition. Then there are 20-4 = 16 sequences that DO satisfy the condition.
Case 4: There are exactly 4 heads. All such sequences satisfy the condition. There are 6C4 = 15 such sequences.
Case 5: There are exactly 5 heads. All such sequences satisfy the condition. There are 6C5 = 6 such sequences.
Case 6: There are exactly 6 heads. All such sequences satisfy the condition. There is 6C6 = 1 such sequence.
Thus, the total number of sequences that satisfy the condition is 0+0+5+16+15+6+1= 43, out of 26 = 64 total possible sequences of 6 coin flips. 43/64 is the answer.
What about when the number of coin flips n is too large to count manually in the above way?
Let Q(n) be the number of sequences of n coin flips that do NOT satisfy the condition of 2 heads in a row. (Then the number of sequences of n coin flips that DO satisfy the condition is simply 2n - Q(n).)
To count Q(n), we note that a sequence that does NOT satisfy the condition must either end in a heads or a tails.
If the sequence ends in a tails, then all we are left with counting is the number of ways the sequence of the first n-1 coin flips also does NOT satisfy the condition. This is simply Q(n-1).
If the sequence ends in heads, then in order to NOT satisfy the condition, the second to last coin flip must be tails. Then all we are left with counting is the number of ways the sequence of the first n-2 coin flips does NOT satisfy the condition. This is simply Q(n-2).
So Q(n) = Q(n-1) + Q(n-2) (for n>=2). (Interestingly, this equation defines the well-known Fibonacci sequence.) In order to be able to use this equation, we need to provide the initial conditions for when n=0 and n=1. When n=0, we have a sequence of 0 coin flips. There is only 1 such sequence (the empty sequence), and since it does not contain 2 heads in a row, it does NOT satisfy the condition (which is what we are currently trying to count). So Q(0)=1. When n=1, we have a sequence of 1 coin flip. There are 2 such sequences (either the 1 flip is heads or it is tails), and neither of those 2 sequences satisfy the condition of having 2 heads in a row. So Q(1)=2. (We see that the initial conditions are different than those of the Fibonacci sequence, whose first 2 terms are 1 and 1.)
When n is low, such as when n=6, we can use the above equation and initial conditions to calculate Q(n) manually:
Q(0)=1
Q(1)=2
Q(2)=1+2=3
Q(3)=2+3=5
Q(4)=3+5=8
Q(5)=5+8=13
Q(6)=8+13=21
Thus, there are 21 sequences of 6 coin flips that do NOT satisfy the condition of 2 heads in a row. Since there are 26 = 64 total sequences of 6 coin flips, there are 64-21=43 sequences of 6 coin flips that DO satisfy the condition. This matches the result obtained above using the method of splitting into cases.
To solve for larger n, we note that Q(n) = Q(n-1) + Q(n-2) (for n>=2), with Q(0)=1 and Q(1)=2, is what is called a “homogeneous linear recurrence relation of order 2 with constant coefficients.” We can solve for an explicit (non-recursive) formula for Q(n) (that doesn’t depend on Q(n-1) or Q(n-2)) to calculate Q(n) directly, instead of having to first calculate Q(0), Q(1), Q(2), ...., Q(n-2), Q(n-1) as we did in the n=6 example above.
How to solve for the explicit formula requires a long explanation that I will not write out myself, but it can be found here: https://math.berkeley.edu/~arash/55/8_2.pdf .