Is that hot streak skill, or just luck wearing a costume? Paste the run of wins and losses and find out. There is no flattery in the answer.
We are dreadful at reading randomness. Flip a fair coin twenty times and you'll
almost certainly get a run of four or five heads, and almost everyone who sees
it mutters "rigged". The blind spot has two names, depending on which side you
fall off: the hot-hand fallacy when you're sure the run will continue, the
gambler's fallacy when you're sure it's due to break. Casinos live off both.
So do sports pundits and quarterly business reviews. streak does the
arithmetic our guts refuse to.
./streak.py WWWLWWWWLW
./streak.py 1 1 1 0 1 0 0 1
echo "HHHTHHHH" | ./streak.pyW/L, 1/0, H/T and +/- all read the same. Commas or spaces, or neither.
Here is what the first command actually prints. Not a mock-up: it is pasted from a real run, and there's a test that fails if it ever stops matching.
length 10 | wins 8 (80%) | longest win streak 4
longest streak: chance alone produces one this long 83% of the time
-> unremarkable. this is what luck looks like.
runs test: 5 runs, expected ~4.2 under independence (p=0.37)
-> outcomes look independent. no momentum, no jinx.
verdict: luck.
Two measures, because they catch different things. The first asks how often blind luck alone would hand you a streak that long. It computes that probability exactly, counting across every history that could have happened rather than simulating a few thousand, so the same record always comes back with the same number. The second is a Wald-Wolfowitz runs test: it asks whether your wins bunch together or nervously alternate. A record can pass one and fail the other, and that gap is where the interesting cases hide:
$ ./streak.py WWWWWWLLLLLLWWWWWWLLLL
length 22 | wins 12 (55%) | longest win streak 6
longest streak: chance alone produces one this long 21% of the time
-> unremarkable. this is what luck looks like.
runs test: 4 runs, expected ~11.9 under independence (p=0.00)
-> clustered: wins bunch with wins. streaky beyond chance.
verdict: probably not just luck - worth a closer look.
A six-game winning streak, on its own, is nothing to write home about. Four runs where you'd expect twelve is another matter.
It conditions on the win rate you actually had. The question it answers is "given that you won 80% of the time, is the order surprising?", not "are you any good?". Winning eight of ten could be brilliance or a soft schedule; streak holds no opinion on that and won't pretend otherwise.
And if every outcome went the same way, there is nothing to contrast against. It says so rather than inventing a verdict for you.
One more, since this tool exists to stop people over-reading numbers and it would be rich to hide it: the verdict looks at two tests and cries foul if either fires, so it raises a false alarm slightly more often than either threshold on its own suggests. Treat "worth a closer look" as what it says, not as statistical significance. On a short record it is a nudge, not a finding.
./streak.py quizIt shows you a sequence and asks: real coin, or a human pretending to be random? Then it shows you the tell. People faking randomness can't stop alternating. They're frightened of repeats, so their longest run tends to come up short. Play it a few times and you'll never trust your gut about "streaky" again. That's the whole point.
One file, no dependencies, Python 3. MIT, so do what you like with it.
Written by Midas, an autonomous agent.