Are You Random? The Math Behind the Oracle
After reading this you will understand why a tiny lookup table can predict your "random" key presses above 60% of the time, how the 5-gram predictor works, and how to read its accuracy without fooling yourself.
What the oracle does and why it wins
You press Left or Right in whatever order feels random. Before each press, the machine guesses which key you will hit. Against a fair coin it can never do better than 50% in the long run. Against a human it usually climbs past 60%, and sometimes past 70%.
The idea comes from a classroom demonstration Scott Aaronson used: a short program that records the recent history of your choices and bets on whatever followed that history most often before. There is no learning network and no trick. There is a table of counts and a majority vote.
The reason it works: your presses are not random. Humans avoid long runs, alternate too much, and settle into rhythms like LRLR or LLRR. Each of those habits is a pattern, and a pattern is exactly what a counting table detects.
When to use it, and when not to
Use the oracle when you want to feel, in real numbers, how bad people are at generating randomness by hand. It makes a concrete point: if you need unpredictable output for a password, a shuffle, or a nonce, you cannot produce it from your own head. You need a real source.
Do not use it to test a physical process. A coin, a die, or a hardware random number generator will hold the oracle to 50%, but so would a fixed alternating sequence over some prediction schemes, so 50% alone does not prove quality. For that, go to a proper coin or dice tool and look at run lengths and frequencies. The oracle answers one narrow question: can a simple predictor beat you?
The oracle is a mirror, not a certifier. It shows that your keyboard-driven "randomness" has structure. It cannot tell you that a source is cryptographically secure, because a source can defeat this predictor and still be predictable in some other way.
The 5-gram predictor
An n-gram is a window of the last n symbols. The oracle uses n = 5: it looks at your last five presses, treats that string as a key, and asks a table what came next the last time it saw that exact key.
Here w is the window of your last five presses (for example LRRLR), C(w, s) is how many times symbol s followed that window earlier in the session, and \hat{x}_{t} is the prediction for your next press. The machine bets on whichever of L or R has the larger count. Ties break arbitrarily, often toward the last seen or a coin flip.
After you actually press, the table updates: C(w, x_t) increases by one. So the predictor keeps sharpening its picture of your habits as you play. With two symbols and a window of five, there are 2^5 = 32 possible windows. Each has its own count of what usually follows.
Why 50% is the ceiling against a coin
Suppose the presses are genuinely independent, each Left or Right with probability 0.5. Then knowing the last five presses tells you nothing about the next one. Whatever the counts say, the true probability of the next symbol is still 0.5.
So the predictor's accuracy is the accuracy of guessing a fair coin: 0.5. Over 200 presses you expect 100 correct, with a standard deviation of \sqrt{200 \cdot 0.5 \cdot 0.5} \approx 7.07 presses. That is why the observed rate wobbles roughly between 43% and 57% by luck alone. It does not climb.
When a human plays, the next press is not independent of the last five. If you almost never press L a sixth time after LLLLL, the count C(\text{LLLLL}, R) dominates, and the machine predicts R and is usually right. Any such bias above 50% is what the oracle harvests.
Reproducing the demo with a short human-like sequence
The demo uses the field defaults, which is simply a fresh session of your own presses. To make the mechanism concrete, take a short window size of n = 2 and this 12-press sequence that alternates too much, a classic human habit:
L R L R R L R L R L R L
- The first two presses seed the window. No prediction is scored yet. Window becomes
LR. - Press 3 is
L. The table has never seenLR, so the guess is a coin flip. Say it misses. RecordC(LR, L) = 1. Window is nowRL. - Press 4 is
R. WindowRLis new, coin flip, call it a miss. RecordC(RL, R) = 1. WindowLR. - Press 5 is
R. WindowLRhasC(LR, L) = 1, so the machine predictsL. You pressedR: miss. RecordC(LR, R) = 1. WindowRR. - Press 6 is
L. WindowRRnew, coin flip. RecordC(RR, L) = 1. WindowRL. - Press 7 is
R. WindowRLhasC(RL, R) = 1, predictsR: hit. Update to2. WindowLR. - From here the alternating
...R L R L R Lkeeps landing in windowsRLandLR, whose counts now favor the alternating continuation. Presses 8 through 12 are predicted correctly.
Of the seven scored presses (3 through 12, minus the seeded flips), five land as the counts mature. The accuracy on a 12-press toy run is already about 0.58. Over 200 presses of the same alternating habit it would settle near 0.75, because the two alternating windows almost always repeat.
To starve the oracle, you must produce genuine independence, not just "mix it up". The moment you try to feel balanced, you introduce the alternation and run-avoidance the table feeds on.
Reading the accuracy line
Watch the running accuracy, not any single guess. The chart below shows the two regimes: a true coin hovering at 0.5, and a human sliding upward as the table fills.
Below 100 presses the accuracy jumps around by luck. With 50 scored presses the standard deviation of the accuracy under a fair coin is about \sqrt{0.5 \cdot 0.5 / 50} \approx 0.071, so a reading of 0.57 means little. By 200 presses that standard deviation falls to about 0.035, so anything consistently above 0.55 is real structure, not chance.
Common mistakes that feed the machine
Three habits account for most of the oracle's edge:
- Alternating too much. A fair coin repeats the previous symbol half the time. Humans repeat far less, so windows like
LRandRLpoint straight back to alternation. - Avoiding long runs. In 100 fair flips you almost always get a run of five or more identical outcomes. If you flinch at pressing
Lfive times in a row, the windowLLLLreliably predictsR. - Falling into rhythm. Blocks like
LLRRrepeated under a steady tempo create windows whose counts are almost deterministic.
Judging the machine before 100 presses is its own mistake: you will see 0.60 by luck, quit, and conclude nothing. Play at least 200 presses before trusting the number.
Related tools
To generate output the oracle cannot beat, use a real source. The Coin Flip flips one coin or a thousand and shows run lengths, which is the honest way to see what independence looks like. The Dice Roller handles RPG notation with per-roll statistics. For exact odds behind any dice expression, the Dice Probability Lab computes the full distribution. And the Wheel Spinner picks from your own list without any human pattern leaking in.
Frequently asked questions
Can I ever beat the oracle?
Yes, if you feed it genuine randomness. Read digits from a coin you actually flip, or from an external random sequence, and enter them one at a time. The accuracy will settle near 0.50. The catch is that you must not filter what the source gives you, because filtering reintroduces a pattern.
Why does the accuracy sometimes start above 60% almost immediately?
Small samples are noisy. With only 20 scored presses, a fair coin already produces a reading above 0.60 about 20% of the time by chance. The number means something only after roughly 100 to 200 presses.
Does a longer window make the machine smarter?
Up to a point. A window of five captures most short human rhythms without splitting the data too thinly. Two symbols and five slots give 32 windows, so a few hundred presses populate them well. A window of ten would give 1024 windows and rarely see any of them twice in one session, so the counts stay empty and predictions revert to coin flips.
Is my sequence sent anywhere?
No. Everything runs in your browser. Nothing you press or generate leaves your device.