Coin Toss Streak Calculator
Whatever math problem related to the probability of obtaining a streak in coin tosses brought you here, you're at the right place — Omni's coin toss streak calculator will help you learn all the interesting things stemming from this simple observation that sometimes consecutive heads appear when we toss a coin (to our Witcher of course). In the article below we:
- Tell you what coin flip streaks are;
- Go through examples of computing the probability of runs in coin tosses; and
- Explain how to derive a formula for the probability of runs in coin flips.
What are streaks in coin flips?
When you toss a coin it can come up heads or tails. We talk about streaks (or runs) when we're interested in getting the same result several times in a row. Most often, we're interested in the longest streak in a given number of tosses.
In contrast to the standard coin toss problem, where we only care about how many heads appeared in a given number of flips, in the streak problem the order of getting the results matters: in
HHHTH there's a streak of
3 heads in
5 coin flips, which is different from
HHTHH containing a run of
2 heads, even though in both cases we have
4 heads in total.
Computing the probability of runs in coin flips in not a trivial problem. Before we dive into the theory and discuss how to derive a formula for the probability of runs in coin toss, let's quickly explain how our coin toss streak calculator works, so that you can use it as we go through the calculations.
How to use this coin toss streak calculator?
To determine the probability of runs in coin flips with our coin toss streak calculator, follow these steps:
- Tell us how many coin tosses there are in total.
- Enter the length of streaks you're interested in.
- Finally, tell us if you're interested in:
- streaks of exactly this length;
- streaks of at least this length; or
- streaks of at most this length.
- The results will appear underneath. If there's 30 flips of less, you can choose between the exact probability (in the form of a fraction) and its approximation.
- Also, if you wish, we will display the plot of the probability distribution of the streak you're interested in. This feature is available for up to 100 tosses.
Play for a little while with the coin toss streak calculator to get the gist of the math challenge at hand before we get our hands dirty with some computations.
Examples of runs probability in coin flips
We'll start softly by going through an example of three coin flips. Obviously, there's eight possible results:
HHH, HHT, HTH, THH, HTT, THT, TTH, TTT
The lengths of the longest streak of heads are, respectively:
3, 2, 1, 2, 1, 1, 1, 0
and so we get the following distribution:
exact streak length
That is, in words, there's
25% chance that we'll get the streak of exactly two heads while tossing a coin three times. You can verify these results with the help of our coin toss streak calculator.
🔎 Observe that the above exact distribution is not symmetric!
Now it's easy to find the probability of getting streaks of at least or at most some length. It's logical that we're interested in them, because the streak of three heads contains a streak of two heads, right?
Let's repeat what we've done above and note that there is:
- one result (
HHH) that has at least three heads in a row
- three results (
HHH, HHT, THH) that have at least two heads in a row
- seven results (all except
TTT) that have at least one head in a row (the concept of heads in a row becomes more abstract now but bear with us)
- eight results (so all of them) that have at least zero heads in a row (so any result will do).
This can be summarized as follows:
min streak length
As for the streaks of at most some length, we very similarly deduce that there is:
- one result (
TTT) that has at most zero heads in a row.
- five results (
TTT, HTH, HHT, THH) that have at most one heads in a row.
- seven results (all except
HHH) that have at most two heads in a row.
- eight results (all) that have at most three heads in a row (because there's three coin tosses in total).
max streak length
🔎 Observe that the min length and max length tables are not mirror images one of the other!
It turns out the easiest value to derive here is the probability of a max streak length. Then, from it, we can easily obtain the remaining two. Let's go!
How to find the probability of streaks in coin toss?
From this point forward, we'll use to denote the length of the longest streak of heads in a string of fair coin flip outcomes. Recall that each possible coin toss sequence resulting from coin tosses has the same probability . Hence, the probability that the longest run of heads will consist of or fewer heads is . Here, denotes the number of results that contain streaks of heads whose length does not exceed .
Our task is, therefore, to find a way to compute . It's obvious that if then , because we cannot get a streak longer than the total number of cases. Therefore, we assume .
Imagine you start tossing the coin. At some point, you start getting consecutive heads. As they appear, you get more and more nervous — because you don't want to observe more than heads in a row (I feel you can feel that pressure growing). But, suddenly, phew, what a relief — there's tails! The game is in fact re-set: we will start counting the streak of heads from zero again.
In fact, this simple observation is the main principle on which the reasoning here is based! More precisely, what matters is how long you wait till your first
- If you got
Tin the very first toss, then there's sequences having at most consecutive heads in the remaining tosses.
- If you started with
HT, then there's sequences having at most consecutive heads in the remaining tosses.
- If you started with
HHT, then there's sequences having at most consecutive heads in the remaining tosses.
- And so on. We bet you can see the rule.
- The longest you can wait for your first
Tis until the -th toss. (Otherwise you'd get more than consecutive heads and it's a game over). Then there's sequences having at most consecutive heads in the remaining tosses.
Since we consider strings of results that have different beginnings (
T, HT, HHT, etc.), we're sure not to count anything twice. So we can safely sum what we got above to get the total number of strings that have no streaks of more than
Clearly, to actually compute the values of using the recurrence relations given above, we need the initial conditions. That is, the values of for small values of . In fact, we need of them: . And then we will be able to compute as the sum of these initial values.
So what are these initial values? Note there's fewer coin tosses than the length of head streak we consider. Oh, we've already discussed this case and it was just the powers of two: . In particular, because if we don't toss, the only possible result is the empty string, and it definitely contains no consecutive heads (it does not contain anything, in fact).
Okay, so we now know how to determine the probability that the longest streak of heads does not exceed some given length. This is what we've referred to as the at-most case. How to derive the exact and at-least thing?
The at-least case calls for the complement of the at-most case. That is, the probability that the longest streak of heads is of length at least reads:
Finally, the probability that the longest streak in tosses is exactly of length is simply the difference between it being of length at most and at most :
🙋 If you're familiar with the language of probability theory, you can easily recognize that we've just calculated the probability mass function from the cumulative distribution function.
Consecutive heads & k-step Fibonacci sequences
Let's discuss in more details the case of . Rewriting the formula for from the previous section, we obtain:
The initial condition are and . Then we get , , . Yes, you've recognized it correctly! What we've got here the the world-famous Fibonacci seqence (even though the indices are slightly shifted)! Wow, we knew that Fibonacci numbers appear everywhere, but have you expected them here? 🤯
For larger values of we obtain the so-called m-step Fibonacci sequence with . The idea is that the next term is the sum of the previous terms. So, for we've had 2-step Fibonacci sequence (just the standard Fibonacci), for we'll get 3-step Fibonacci sequence, etc. Here's a quick summary of them:
Several initial terms
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233
1, 2, 4, 7, 13, 24, 44, 81, 149, 274, 504, 927
1, 2, 4, 8, 15, 29, 56, 108, 208, 401, 773, 1490
1, 2, 4, 8, 16, 31, 61, 120, 236, 464, 912, 1793
1, 2, 4, 8, 16, 32, 63, 125, 248, 492, 976, 1936
1, 2, 4, 8, 16, 32, 64, 127, 253, 504, 1004, 2000
1, 2, 4, 8, 16, 32, 64, 128, 255, 509, 1016, 2028
1, 2, 4, 8, 16, 32, 64, 128, 256, 511, 1021, 2040
1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1023, 2045
🙋 The prefixes above (tri-, tetra-, penta-, etc) correspond to numbers in the great Greek language. You've certainly seen them already in words like triangle, tetrahedron, pentagon, etc. They just tell us how many previous terms we need to add up to get the next term: for Tetranacci it's four, for Octonacci it's eight, etc.
Finding the coin toss streak probability — an example
Let's find the probability of getting a streak of at least 3 heads with 10 flips. According to what we've established above, we have
and is the tenth term of the Tribonacci sequence (). Looking into the table above, we see (remember, the term numbering starts from zero). As a result, we get:
So you have around a fifty percent chance of getting a streak of at least three heads if you flip a coin ten times. Pretty high chance, isn't it? For at least four consecutive heads the probability falls to around 25%, for streaks of five heads or more it's still around 10%, and then for six it's a bit less than 5%.
What is a recurrence relation?
A recurrence relation means that the
n-th term of a sequence is expressed as some combination (e.g., a sum) of the previous terms of this sequence. A sufficient number of initial values must be defined for this procedure to work!
How do I find the probability of streaks in coin toss?
To find the probability of the length of the longest head run not exceeding
2to the power of
nis the total number of coin flips you perform.
- Determine the
n-th term of the
(k+1)-step Fibonacci sequence.
- Divide the number obtained in Step 2 by that from Step 1.
- What you got is exactly the probability we've been looking for!
What is the probability of no consecutive heads in 3 coin flips?
The probability that in 3 coin tosses you'll get no consecutive heads is
62.5%. The possible sequences you can obtain with 3 coin tosses are
HHH, HHT, HTH, THH, HTT, THT, TTH, TTT. Of these 8 possible sequences, 5 have no consecutive heads:
HTH, HTT, THT, TTH, TTT. Therefore, the probability is
5/8, which is
What is the probability of no consecutive heads in 10 coin flips?
The probability that no consecutive heads come up in 10 coin flips is around