Bayesian Inference (Bayes' Theorem)
Bayesian inference is a method of statistical inference that uses Bayes' Theorem to update the probability of a hypothesis as more evidence becomes available, combining prior beliefs with observed data.
THE IDEA
RADIO PSYCHICS AND THE RULE OF BAYES
Consider Jordan Ellenberg’s example of a hypothetical Facebook algorithm that flags potential terrorists. Knowing what proportion of people it flags (about 1 in 2,000) does not tell you the probability that a flagged person is a terrorist. You also need to consider how rare terrorists are in the population. When you're trying to decide whether your neighbor is a secret terrorist, that is critical prior information. Just as R. A. Fisher said, you have to evaluate each hypothesis in the "light of the evidence" of what you already know about it.
But how do you do that?
This brings us to the story of the radio psychics.
In 1937, telepathy was the rage. Psychologist J. B. Rhine's book New Frontiers of the Mind, which presented extraordinary claims about Rhine's ESP experiments at Duke in a soothingly sober and quantitative tone, was a best seller and a Book-of-the-Month Club selection, and psychic powers were a hot topic of cocktail conversation across the country. Upton Sinclair, the best-selling author of The Jungle, released in 1930 a whole book, Mental Radio, about his experiments in psychic communication with his wife, Mary; the subject was mainstream enough that Albert Einstein contributed a preface to the German edition, stopping short of endorsing telepathy, but writing that Sinclair's book "deserves the most earnest consideration" from psychologists.
Naturally, the mass media wanted in on the craze. On September 5, 1937, the Zenith Radio Corporation, in collaboration with Rhine, launched an ambitious experiment of the kind only the new communication technology they commanded made possible. Five times, the host spun a roulette wheel, with a panel of self-styled telepaths looking on. With each spin, the ball landed either in the black or in the red, and the psychics concentrated with all their might on the appropriate color, transmitting that signal across the country over their own broadcast channel. The station's listeners were implored to use their own psychic powers to pick up the mental transmission and to mail the radio station the sequence of five colors they'd received. More than forty thousand listeners responded to the first request, and even for later programs, after the novelty was gone, Zenith was getting thousands of responses a week. It was a test of psychic powers on a scale Rhine could never have carried out subject by subject in his office at Duke, a kind of proto−Big Data event.
The results of the experiment were not, in the end, favorable to telepathy. But the accumulated data of the responses turned out to be useful for psychologists in a totally different way. The listeners were trying to reproduce sequences of blacks and reds (hereafter Bs and Rs) generated by five spins of the roulette wheel. There are 32 possible sequences:
| BBBBB | BBRBB | BRBBB | BRRBB |
| BBBBR | BBRBR | BRBBR | BRRBR |
| BBBRB | BBRRB | BRBRB | BRRRB |
| BBBRR | BBRRR | BRBRR | BRRRR |
| RBBBB | RBRBB | RRBBB | RRRBB |
| RBBBR | RBRBR | RRBBR | RRRBR |
| RBBRB | RBRRB | RRBRB | RRRRB |
| RBBRR | RBRRR | RRBRR | RRRRR |
In this simplified red-or-black model, the spins are independent and each color is equally likely, so all these sequences have the same probability. And since the listeners weren't actually receiving any psychic emanations, you might expect that their responses, too, would be drawn equally from the thirty-two choices.
But no. In fact, the cards the listeners mailed in were highly nonuniform. Sequences like BBRBR and BRRBR were offered much more frequently than chance would predict, while sequences like RBRBR were less frequent than they ought to have been, and RRRRR almost never showed up.
This probably doesn't surprise you. RRRRR somehow doesn't feel like a random sequence the way BBRBR does, even though the two are equally likely to occur when we spin the wheel. What's going on? What do we really mean when we say that one sequence of letters is "less random" than another?
Here's another example. Quick, think of a number from 1 to 20.
Did you pick 17?
Okay, that trick doesn't always work—but if you ask people to pick a number between 1 and 20, 17 is the most common choice. And if you ask people for a number between 0 and 9, they most frequently pick 7. Numbers ending in 0 and 5, by contrast, are chosen much more rarely than chance would lead you to expect—they just seem less random to people. This leads to an irony. Just as the radio psychic contestants tried to match random sequences of Rs and Bs and produced notably nonrandom results, so people who choose random numbers tend to make choices that visibly deviate from randomness.
In 2009, Iran held a presidential election, which incumbent Mahmoud Ahmadinejad won by a large margin. There were widespread accusations that the vote had been fixed. But how could you hope to test the legitimacy of the vote count in a country whose government allowed for almost no independent oversight?
Two graduate students at Columbia, Bernd Beber and Alexandra Scacco, had the clever idea to use the numbers themselves as evidence of fraud, effectively compelling the official vote count to testify against itself. They looked at the official total amassed by the four main candidates in each of Iran's twenty-nine provinces, a total of 116 numbers. If these were true vote counts, there should be no reason for the last digits of those numbers to be anything but random. They should be distributed just about evenly among the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9, each one appearing 10% of the time.
That's not how the Iranian vote counts looked. There were too many 7s, almost twice as many as their fair share; not like digits derived from a random process, but very much like digits written down by humans trying to make them look random. This, by itself, isn't proof that the election was fixed, but it's evidence in that direction.
Human beings are always inferring, always using observations to refine our judgments about the various competing theories that jostle around inside our mental representation of the world. We are very confident, almost unshakably confident, about some of our theories ("The sun will rise tomorrow," "When you drop things, they fall") and less sure about others ("If I exercise today, I'll sleep well tonight," "There's no such thing as telepathy"). We have theories about big things and little things, things we encounter every day and things we've run into only once. As we encounter evidence for and against those theories, our confidence in them bobs up and down.
For this example, we use a simplified roulette wheel with only red and black outcomes. Our standard theory is that the colors are equally likely on each independent spin. But there are competing theories—say, that the wheel is biased in favor of one color or the other. Let's simplify matters and suppose there are just three theories available to you:
RED: The wheel is biased to make the ball land on red 60% of the time.
FAIR: The wheel is fair, so the ball lands on red half the time and on black half the time.
BLACK: The wheel is biased to make the ball land on black 60% of the time.
How much credence do you assign to these three theories? You probably tend to think roulette wheels are fair, unless you have reason to believe otherwise. Maybe you think there's a 90% chance that FAIR is the right theory, and only a 5% chance for each of BLACK and RED. These are what we call in probability lingo the a priori probabilities that the different theories are correct; the prior, for short. Different people might have different priors; a hard-core cynic might assign a 1/3 probability to each theory, while someone with a really firm preexisting belief in the rectitude of roulette-wheel makers might assign only a 1% probability to each of RED and BLACK.
But those priors aren't fixed in place. If we're presented with evidence favoring one theory over another—say, the ball landing red five times in a row—our levels of belief in the different theories can change. How might that work in this case? We can work it out by computing the conditional probabilities.
How likely is it that we'll spin the wheel five times and get RRRRR? The answer depends on which theory is true. Under the FAIR theory, each spin has a 1/2 chance of landing on the red, so the probability of seeing RRRRR is
(1/2) × (1/2) × (1/2) × (1/2) × (1/2) = 1/32 = 3.125%.
In other words, RRRRR is exactly as likely as any of the other 31 possibilities.
But if BLACK is true, there's only a 40%, or 0.4 chance of getting red on each spin, so the chance of RRRRR is
(0.4) × (0.4) × (0.4) × (0.4) × (0.4) = 1.024%.
And if RED is true, so that each spin has a 60% chance of landing red, the chance of RRRRR is
(0.6) × (0.6) × (0.6) × (0.6) × (0.6) = 7.776%.
For each of the three theories—BLACK, FAIR, and RED—consider two cases: getting RRRRR and not getting RRRRR. Together, these make six possible cases. We can now calculate the joint probabilities. For instance, the a priori probability that FAIR is the correct theory is 0.9. And 3.125% of this probability, 0.9 × 0.03125, or about 0.0281, goes in the box where FAIR is correct and the balls fall RRRRR. The other 0.8719 goes in the "FAIR correct, not RRRRR" box, so that the FAIR column still adds up to 0.9 in all.
The a priori probability of being in the RED column is 0.05. So the chance that RED is true and the balls fall RRRRR is 7.776% of 5%, or 0.0039. That leaves 0.0461 to sit in the "RED true, not RRRRR" box.
The BLACK theory also has an a priori probability of 0.05. But that theory doesn't jibe nearly as well with seeing RRRRR. The chance that BLACK is true and the balls fall RRRRR is just 1.024% of 5%, or .0005.
The probabilities of all six cases add up to 1, because together they cover all possible situations.
What happens to our theories if we spin the wheel and we do get RRRRR? That ought to be good news for RED and bad news for BLACK. And that's just what we see. Getting five reds in a row means we consider only the cases with that outcome. Their joint probabilities are 0.0005 attached to BLACK, 0.028 attached to FAIR, and 0.0039 attached to RED. In other words, given that we saw RRRRR, our new judgment is that FAIR is about seven times as likely as RED, and RED is about eight times as likely as BLACK.
If you want to translate those proportions into probabilities, you just need to remember that the total probability of all the possibilities has to be 1. The sum of these joint probabilities is about 0.0325, so to make those numbers sum to 1 without changing their proportions to one another, we can just divide each number by 0.0325. This leaves you with
1.5% chance that BLACK is correct
86.5% chance that FAIR is correct
12% chance that RED is correct.
The extent to which you believe in RED has more than doubled, while your belief in BLACK has fallen substantially. As is appropriate! You see five reds in a row, why shouldn't you start to suspect a little more seriously than before that the game is rigged?
That "dividing everything by 0.0325" step might seem a bit of an ad hoc trick. But it's really the correct thing to do. In case your intuition doesn't swallow it right away, here's another picture some people like better. Imagine there are ten thousand roulette wheels. And there are ten thousand rooms, each with a different roulette wheel, each roulette wheel with a person playing it. One of those people, following one of those wheels, is you. But you don't know which wheel you've got! So your state of unknowledge about the wheel's true nature can be modeled by supposing that, of the original ten thousand, five hundred were biased toward the black, five hundred were biased toward the red, and nine thousand were fair.
The computation we just did above tells you to expect about 281 of the FAIR wheels, about 39 of the RED wheels, and only 5 of the BLACK wheels to come up RRRRR. So if you do get RRRRR, you still don't know which of the ten thousand rooms you're in, but you've narrowed it down a hell of a lot; you're in one of the 325 rooms where the ball landed on red five times in a row. And of those rooms, 281 of them (about 86.5%) have FAIR wheels, 39 (12%) have RED wheels, and only 5 (1.5%) have BLACK wheels.
The more balls that fall red, the more favorably you're going to look on that RED theory (and the less credence you'll give to BLACK). If you saw ten reds in a row instead of five, the same computation would raise your estimation of the chance of RED to 25%.
What we've done is to compute how our degrees of belief in the various theories ought to change once we see five reds in a row—what are known as the posterior probabilities. Just as the prior describes your beliefs before you see the evidence, the posterior describes your beliefs afterward. What we're doing here is called Bayesian inference, because the passage from prior to posterior rests on an old formula in probability called Bayes's Theorem. That theorem is a short algebraic expression and I could write it down for you right here and now. But I'm going to try not doing that. Because sometimes a formula, if you train yourself to apply it mechanically without thinking about the situation in front of you, can obscure what's really going on. The calculation above shows how the update works.
—
The posterior is affected by the evidence you encounter, but also by your prior. The cynic, who started out with a prior that assigned probability 1/3 to each of BLACK, FAIR, and RED, would respond to five reds in a row with a posterior judgment that RED had a 65% chance of being correct. The trusting soul who starts out assigning only 1% probability to RED will still give it only a 2.5% chance of being right, even after seeing five reds in a row.
In the Bayesian framework, how much you believe something after you see the evidence depends not just on what the evidence shows, but on how much you believed it to begin with.
That may seem troubling. Isn't science supposed to be objective? You'd like to say that your beliefs are based on evidence alone, not on some prior preconceptions you walked in the door with. But let's face it—no one actually forms their beliefs this way. If an experiment provided statistically significant evidence that a new tweak of an existing drug slowed the growth of certain kinds of cancer, you'd probably be pretty confident the new drug was actually effective. But if you got the exact same results by putting patients inside a plastic replica of Stonehenge, would you grudgingly accept that the ancient formations were actually focusing vibrational earth energy on the body and stunning the tumors? You would not, because that's nutty. You'd think Stonehenge probably got lucky. You have different priors about those two theories, and as a result you interpret the evidence differently, despite it being numerically the same.
It's just the same with Facebook's terrorist-finding algorithm and the next-door neighbor. The neighbor's presence on the list really does offer some evidence that he's a potential terrorist. But your prior for that hypothesis ought to be very small, because most people aren't terrorists. So, despite the evidence, your posterior probability remains small as well, and you don't—or at least shouldn't—worry.
Relying purely on null hypothesis significance testing is a deeply non-Bayesian thing to do—strictly speaking, it asks us to treat the cancer drug and the plastic Stonehenge with exactly the same respect. Is that a blow to Fisher's view of statistics? On the contrary. When Fisher says that "no scientific worker has a fixed level of significance at which from year to year, and in all circumstances, he rejects hypotheses; he rather gives his mind to each particular case in the light of his evidence and his ideas," he is saying exactly that scientific inference can't, or at least shouldn't, be carried out purely mechanically; our preexisting ideas and beliefs must always be allowed to play a part.
Not that Fisher was a Bayesian statistician. That phrase, nowadays, refers to a cluster of practices and ideologies in statistics, once unfashionable but now rather mainstream, which includes a general sympathy toward arguments based on Bayes's Theorem, but is not simply a matter of taking both previous beliefs and new evidence into account. Bayesianism tends to be most popular in genres of inference, like teaching machines to learn from large-scale human input, that are poorly suited to the yes-or-no questions Fisher's approach was set up to adjudicate. In fact, Bayesian statisticians often don't think about the null hypothesis at all; rather than asking "Does this new drug have any effect?" they might be more interested in a best guess for a predictive model governing the drug's effects in various doses on various populations. And when they do talk about hypotheses, they're relatively at ease with talking about the probability that a hypothesis—say, that the new drug works better than the existing one—is true. Fisher was not. In his view, the language of probability was appropriately used only in a context where some actual chance process was taking place.
At this point, we've arrived at the shore of a great sea of philosophical difficulty, into which we'll dip one or two toes, max.
Bayes's Theorem follows from the rules of probability. The philosophical dispute concerns how we interpret and assign those probabilities—what we mean when we say "probability." When we say that there's a 5% chance that RED is true, we might mean that there actually is some vast global population of roulette wheels, of which exactly one in twenty is biased to fall red 3/5 of the time, and that any given roulette wheel we encounter is randomly picked from the roulette wheel multitude. If that's what we mean, then Bayes's Theorem is a plain fact, akin to the Law of Large Numbers; it says that, in the long run, under the conditions we set up in the example, 12% of the roulette wheels that come up RRRRR are going to be of the red-favoring kind.
But this isn't actually what we're talking about. When we say that there's a 5% chance that RED is true, we are making a statement not about the global distribution of biased roulette wheels (how could we know?) but rather about our own mental state. Five percent is the degree to which we believe that a roulette wheel we encounter is weighted toward the red.
This is the point at which Fisher totally got off the bus, by the way. He wrote an unsparing pan of John Maynard Keynes's Treatise on Probability, in which probability "measures the 'degree of rational belief' to which a proposition is entitled in the light of given evidence." Fisher's opinion of this viewpoint is well summarized by his closing lines: " If the views of the last section of Mr. Keynes's book were accepted as authoritative by mathematical students in this country, they would be turned away, some in disgust, and most in ignorance, from one of the most promising branches of applied mathematics."
For those who are willing to adopt the view of probability as degree of belief, Bayes's Theorem can be seen not as a mere mathematical equation but as a form of numerically flavored advice. It gives us a rule, which we may choose to follow or not, for how we should update our beliefs about things in the light of new observations. In this new, more general form, it is naturally the subject of much fiercer disputation. There are hard-core Bayesians who think that all our beliefs should be formed by strict Bayesian computations, or at least as strict as our limited cognition can make them; others think of Bayes's rule as more of a loose qualitative guideline.
The Bayesian outlook is already enough to explain why RBRRB looks random while RRRRR doesn't, even though both are equally improbable. When we see RRRRR, it strengthens a theory—the theory that the wheel is rigged to land red—to which we've already assigned some prior probability. But what about RBRRB? You could imagine someone walking around with an unusually open-minded stance concerning roulette wheels, which assigns some modest probability to the theory that the roulette wheel was fitted with a hidden Rube Goldberg apparatus designed to produce the outcome red, black, red, red, black. Why not? And such a person, observing RBRRB, would find this theory very much bolstered.
But this is not how real people react to the spins of a roulette wheel coming up red, black, red, red, black. We don't allow ourselves to consider every cockamamie theory we can logically devise. Our priors are not flat, but spiky. We assign a lot of mental weight to a few theories, while others, like the RBRRB theory, get assigned a probability almost indistinguishable from zero. How do we choose our favored theories? We tend to like simpler theories better than more complicated ones, theories that rest on analogies to things we already know about better than theories that posit totally novel phenomena. That may seem like an unfair prejudice, but without some prejudices we would run the risk of walking around in a constant state of astoundedness. Richard Feynman famously captured this state of mind:
You know, the most amazing thing happened to me tonight. I was coming here, on the way to the lecture, and I came in through the parking lot. And you won't believe what happened. I saw a car with the license plate ARW 357. Can you imagine? Of all the millions of license plates in the state, what was the chance that I would see that particular one tonight? Amazing!
If you've ever used America's most popular sort-of-illegal psychotropic substance, you know what it feels like to have too-flat priors. Every single stimulus that greets you, no matter how ordinary, seems intensely meaningful. Each experience grabs hold of your attention and demands that you take notice. It's a very interesting mental state to be in. But it's not conducive to making good inferences.
The Bayesian point of view explains why Feynman wasn't actually amazed; it's because he assigns a very low prior probability to the hypothesis that a cosmic force intended him to see the license plate ARW 357 that night. It explains why five reds in a row feels "less random" than RBRRB to us; it's because the former activates a theory, RED, to which we assign some non-negligible prior probability, and the latter doesn't. And a number ending in 0 feels less random than a number ending in 7, because the former supports the theory that the number we're seeing is not a precise count, but an estimate.
This framework also helps explain our reactions to repeated lottery results. Why are we surprised and a little suspicious when the lottery comes up 4, 21, 23, 34, 39 twice in a row, but not when it comes up 4, 21, 23, 34, 39 one day and 16, 17, 18, 22, 39 the next day, even though both events are equally improbable? Implicitly, you have some kind of theory in the back of your mind, a theory that lottery games are for some reason unusually likely to spit out the same numbers twice in close succession; maybe because you think lottery games are rigged by the proprietors, maybe because you think a cosmic synchronicity-loving force has a thumb on the scale, doesn't matter. You might not believe in this theory very strongly; maybe in your heart you think there's a 1 in 100,000 chance that there really is such a bias in favor of repeated numbers. But that's much more than the prior you assign the theory that there's a weird conspiracy in favor of the 4, 21, 23, 34, 39−16, 17, 18, 22, 39 combo. That theory is crazy, and you are not stoned, so you pay it no mind.
If you do happen to find yourself partially believing a crazy theory, don't worry—probably the evidence you encounter will be inconsistent with it, driving down your degree of belief in the craziness until your beliefs come into line with everyone else's. Unless, that is, the crazy theory is designed to survive this winnowing process. That's how conspiracy theories work.
Suppose you learn from a trusted friend that the Boston Marathon bombing was an inside job carried out by the federal government in order to, I don't know, garner support for NSA wiretapping. Call that theory T. At first, because you trust your friend, maybe you assign that theory a reasonably high probability, say 0.1. But then you encounter other information: police located the suspected perpetrators, the surviving suspect confessed, etc. Each of these pieces of information is pretty unlikely, given T, and each one knocks down your degree of belief in T until you hardly credit it at all.
That's why your friend isn't going to give you theory T; he's going to add to it theory U, which is that the government and the news media are in on the conspiracy together, with the newspapers and cable networks feeding false information to support the story that the attack was carried out by Islamic radicals. The combined theory, T + U, cannot have a higher prior probability than T alone: it asks you to accept both T and another theory at the same time. But as the evidence flows in, which would tend to kill T alone, the combined theory T + U remains untouched. Dzhokar Tsarnaev convicted? Well, sure, that's exactly what you'd expect from a federal court—the Justice Department is totally in on it! The theory U acts as a kind of Bayesian coating to T, keeping new evidence from getting to it and dissolving it. This is a property most successful crackpot theories have in common; they're encased in just enough protective stuff that they're equally consistent with many possible observations, making them hard to dislodge. They're like the multi-drug-resistant E. coli of the information ecosystem. In a weird way you have to admire them.
When to use it
Evaluating the reliability of a diagnostic test by considering the base rate of the condition.
Revising a hypothesis during an investigation while considering how likely each finding would be under competing explanations.
Assessing the credibility of a news article by considering prior probabilities of the event and the source's reliability.
Updating an estimate of a production defect rate as inspection results arrive, while checking whether the original assumptions still fit.
FROM THEORY TO EVERYDAY LIFE
In practice
Radio Psychics Experiment
In 1937, a radio experiment asked listeners to guess sequences of red/black from a roulette wheel. The responses showed non-random patterns, demonstrating how people's intuitive randomness is biased. Bayesian reasoning explains why sequences like RRRRR feel less random: they activate a theory of bias with non-negligible prior probability.
Iran Election Vote Counts
In 2009, researchers found an excess of 7s among the last digits of reported vote counts in Iran's presidential election. They treated this as evidence consistent with fabricated numbers, not proof of fraud. The example asks whether the pattern fits honest counts or human attempts to imitate randomness.
A MOMENT TO REFLECT
Put it to work.
Suppose a small experiment supports a claim you initially considered unlikely. What would you need to know about the experiment and competing explanations before updating your belief?
Why does a sequence like RRRRR in roulette seem non-random while RBRRB seems random, even though both are equally probable?
What observation would count against a theory you believe? Can the theory explain away every possible result?
Often confused with
References
- New Frontiers of the Mind — J.B. Rhine (1937)
- Mental Radio — Upton Sinclair (1930)
CONTINUE THE CONVERSATION
Source texts
- How Not to Be Wrong The Power of Mathematical Thinking (Ellenberg, Jordan)