will represent tails. Now lets take a look at streaks of or more heads in a row as well as streaks of or more tails in a row. Heads streaks > are highlighted as

Tails streaks > are highlighted as To explore regression to the mean and the gambler's fallacy, we're interested in knowing what happens immediately after a streak of . So lets pull out: 1. Streaks of 1. Streaks greater than will be split into (streak length) / parts. 2. The coin flip immediately after the streak 3. The set of flips immediately after the streak of . We're interested in (2) so we can verify that the chances of heads/tails after a streak is still 50/50 (**gambler's fallacy**). We're interseted in (3) so we can verify that a series of flips immediately after an outlier (the streak) is, on average, closer to the mean (**regression to the mean**).

Streak | Next Flip | Next Flips | Flips Sum |

Streaks | / | / | of Closer to mean |

/ * 100 = % Note: refreshing this page re-runs the coinflips if you want to run the test multiple times. **Regression to the mean** - The last column is a tally of column 3 where heads = -1 and tails = 1. A magnitude < 4 means that we're closer to the mean than the streak. In the last column, nearly all of the sequences of flips immediatelly following a streak are closer to the mean (i.e., have nearly even numbers of heads and tails). This confirms regression to the mean: after seeing an outlier the next measurement is more likely to be closer to the mean. / * 100 = **%** of runs are **closer to the mean.** But we're taking into consideration both heads streaks and tails streaks. Could they by evening one another out? ### Heads Only To be sure, let's re-do the analysis above but for streaks of heads only.

Streak | Next Flip | Flips After | Flips Sum |

Streaks | / | / | of Closer to mean |

/ * 100 = % **Regression to the Mean:** / * 100 = **%** of runs are **closer to the mean.** These findings corroborate our original findings. ## Conclusion In accord with the gambler's fallacy, every flip is 50/50, regardless of the streak proceeding the flip. Since every flip is 50/50, a streak of heads or tails is a deviation from the mean and an outlier. By definition, flips after a streak (an outlier) are more likely be closer to the mean. Regression to the mean, rather than being contrary to the gambler's fallacy, is really a restatement of it. A sequence of random events will always tend towards the mean. The chance of getting heads or tails on any given flip is the mean. Demo source: * [js](https://github.com/tantaman/tantaman.github.io/blob/master/assets/posts/regression-mean-vs-gambler.js) * [css](https://github.com/tantaman/tantaman.github.io/blob/master/assets/posts/regression-mean-vs-gambler.css) * [markdown/html](https://github.com/tantaman/tantaman.github.io/blob/master/_posts/2021-01-26-regression-mean-vs-gambler.markdown)