Mental Models204 cards · 12 fields

Mental Models/Mathematics & Statistics

Bayesian Updating

贝叶斯更新

Start from a best guess, weigh new evidence, and shift your view bit by bit.

In September 2011, the OPERA team, working under the Gran Sasso mountain in Italy, announced an astonishing reading. The neutrinos they picked up, a kind of particle that can pass through almost anything, were fired from CERN, the European nuclear research center about 730 kilometers away, and flew all the way through the rock underground. The arrival time they measured was about 60 nanoseconds earlier than light would take to cover the same distance (a nanosecond is a billionth of a second). According to Einstein's theory of relativity, nothing can travel faster than light.

The team didn't announce that relativity had been overturned. Instead, they made their data public and asked other scientists to help find the mistake. In February 2012, they found that a fiber-optic cable connector hadn't been plugged in tightly, which could throw off the timing. After fixing it and measuring again, the neutrinos' speed matched the speed of light.

A piece of data that seemed about to rewrite physics in the end could not beat a far more common explanation: something was wrong with the equipment.

You come home from work and find your front door slightly open. You already have a starting point in mind: out of 100 times like this, 95 times a family member didn't close it properly, and 5 times a burglar got in. The ratio of how often each happens is called the odds: 5 to 95, which is 1 to 19.

Then you notice a fresh scratch beside the keyhole. When family members open the door with a key, they leave a scratch 4 times in 100; someone picking the lock leaves one 80 times in 100. 80 divided by 4: a scratch is 20 times as common when the lock is picked. Bayesian updating works by multiplying the burglar side of the odds by this 20: 1 to 19 becomes 20 to 19. That means that out of 39 parts, a burglar accounts for 20, about half. You don't push the door open; first you call your family.

From 5%, one scratch pushes it to about half
Burglar's scratches40 per 1,000
Family's scratches38 per 1,000
Chance of burglar51%
0%25%50%75%100%0%20%40%60%80%100%Burglary, before the scratchAfter the scratchAfter scratchNo new evidenceYour door
0%50%100%0%25%50%75%100%Burglary, before the scratchAfter the scratchAfter scratchNo new evidenceYour door

Count 1,000 nights with the door ajar. At a 5% start, burglars leave 40 scratches and family 38, so a burglar is about half. Drag the start to 1%: only about 17%.

Multiplying the odds is really counting the nights with a scratch

Collect a thousand nights when the door was left open, and count. On 950 nights, family members didn't close it properly, and on 4% of them, that is 38 nights, there was a scratch by the keyhole. On 50 nights a burglar got in, and on 80% of them, that is 40 nights, there was a scratch. The scratch in front of you can only be from one of these 38 plus 40, 78 nights in all, and 40 of them were burglaries, about half.

This 40 to 38 is where the multiplication comes from. The burglar side is 50 times 80%, and the family side is 950 times 4%. Comparing the two sides is the same as taking the starting ratio, 50 to 950, and multiplying it by the ratio of how common the scratch is on each side, 80% to 4% (that is, 20). That second ratio is called the likelihood ratio, written . Write the starting odds as , and the odds after seeing the evidence are

In plain words: the starting odds, times how many times more common the evidence is on one side than the other, give the new odds. Put in the numbers from the front door: , the same ratio as 40 to 38.

When the starting point is very low, even an astonishing piece of data can't push it far

Suppose a burglary starts at only 1%. In a thousand nights, a burglar comes only 10 times and leaves 8 scratches; family come 990 times and leave about 40. Most nights with a scratch still belong to the family, and a burglar accounts for only about 17%.

The OPERA reading works the same way, only from an even lower starting point. All of the following numbers are assumptions. The starting point for faster-than-light being true is one in ten thousand; the starting point for a mistake hiding in a complex experiment is one in twenty, and one in ten such mistakes happens to produce an early arrival this large. If faster-than-light is true, the "early arrival" is bound to appear; if there's a mistake, only one time in ten, so the likelihood ratio is 10. The starting odds are to , that is, . Multiply by 10 to get : the chance that faster-than-light is true is about 2%.

Leave the other numbers as they are and change only the starting point for faster-than-light to one in a hundred. The starting odds become , and times 10 that is two to one: faster-than-light now accounts for about two thirds. The same reading, from different starting points, lands in completely different places.

Only data that tells two explanations apart counts as new evidence

In 2011, OPERA measured again with shorter neutrino pulses, and the reading was the same as before. But if the same timing equipment had a mistake hidden in it, the new measurement would arrive early too. The two explanations predict the same result, so the likelihood ratio is close to one, and the odds barely move. Finding the loose fiber-optic connector was what told the two sides apart: a finding like that only turns up if there's a mistake, and there'd be no reason for it if faster-than-light were true. Once the connector was fixed, the data matched the speed of light, and the odds for faster-than-light fell to nearly zero.

The method is most reliable when two numbers can both be trusted: how common this evidence is under each explanation, and the starting point. Quality control, screening tests and fault-finding are all like this. If the list of candidates leaves out the real cause, the method can only share out confidence among those on the list, and so it pushes you toward the wrong side: you compare only a loose part and old wiring, and miss a software bug. If the starting point is an offhand guess of 30%, reporting 64.7% after multiplying by the likelihood ratio just dresses a guess up in precise-looking clothes.

Act
When tracking down a fault in a new machine, for each candidate cause, look at how common the symptom that just appeared is under that cause, and take apart first the one whose odds rise the most.
Communicate
To explain to a colleague why one rumor didn't make you change plans, say how sure you were to begin with and how common this rumor would be if it were true and if it were false; then they can follow your working and push back on it.
Predict
To estimate the defect rate of the next batch of goods, start from the last batch's rate and revise it each time a new batch's data comes in from inspection; the more batches, the closer the estimate gets to the truth.
  1. Where did my starting confidence come from: a counted share of similar cases, or an offhand guess?
  2. If my judgment is wrong, would this evidence still show up? How many times less often than if my judgment were right?
  3. Of the pieces of evidence I have, how many actually come from the same source?

Technology

Words change the verdict on an email

In 2002, the programmer Paul Graham published "A Plan for Spam," which used Bayes's method to filter junk email. He counted separately how often each word appeared in spam and in normal email. Words like "the" that are everywhere hardly move the verdict at all; each time a word that almost only shows up in spam appears, the odds that the email is spam get multiplied by a large factor. The weights of all the words in the email are combined, and emails over a certain line go to the spam folder.

History

Clues adding up in bans

During World War II at Bletchley Park, Alan Turing and his colleagues, breaking the German navy's Enigma code, recorded each clue's weight as a factor multiplying the odds, then converted it into a unit called the "ban": one ban is a factor of ten, and a tenth of a ban is about 1.26 times. The clues were added up one by one and used to rule out large numbers of rotor settings, leaving only the rest for the codebreaking machines to test.

Personal life

The stain after the main valve is off

A water stain appears in the corner of your bedroom wall. At first you think it's 70% likely a leak from upstairs and 30% likely a pipe inside your own wall (these numbers are assumptions). You turn off your home's main water valve, and the stain stops spreading that same day. If your own pipe is leaking, the stain is sure to stop once the valve is off; if it's a leak from upstairs, the chance the stain stops is only 20%. Three to seven times five makes fifteen to seven, and the chance it's your own pipe rises from 30% to about 70%. You take your hand back from the upstairs doorbell you were about to press, and log a repair request for your own pipes with the building management.

Bayesian UpdatingFalsifiabilityIf you can't say what would prove you wrong, nobody can test your claim.A startup team agrees in advance to shut the project down if daily active users are under 5,000 after three months. This is what falsifiability asks for: the line for the verdict is written down beforehand, and nobody changes their story when the time comes. Bayesian updating revises confidence every week rather than waiting for the deadline. On the day, daily active users are 4,800, just short. Falsifiability says stop, as agreed; Bayesian updating says first look at how that 4,800 came about, and if growth over the last three weeks is still picking up, a small shortfall can't overturn the whole judgment. The agreement guards against a team that can't let go moving the line again and again; updating every week guards against the agreement killing a project that is getting better. If growth is flat, stop at the line; if growth is picking up and the reason can be found, you can extend it once, and write down the new line first.Bayesian UpdatingConfirmation BiasOnce you've settled on an answer, you only notice the evidence that backs it up.A new business partner sends you three letters of recommendation, each praising how reliable he is. Confirmation bias looks at you: you're only asking "how is he reliable," and you read only the parts of the letters that praise him. Bayesian updating questions the letters themselves. He picked the people who wrote them, and even if he weren't reliable he could find three people to say good things, so the likelihood ratio is close to one and the starting point barely moves. To get anywhere, you need people he didn't suggest, such as former colleagues, or suppliers he has paid late.

You find a patch of wilting tomatoes in your vegetable garden. In past years, about 10% of plots that wilted like this had root rot and 90% were short of water. You pull up a plant to look at the roots: 60% of plants with root rot have blackened roots, and 20% of plants short of water do. This plant's roots are black. You pull another plant at the other end of the plot, and its roots are black too; the two plants are independent of each other.

After both have black roots, how likely is it that this plot has root rot?

You send an old classmate who lives far away an invitation to an event. You figured there was a 20% chance the email would be swallowed by his spam folder. If he sees the email, there's a 90% chance he'll reply within two days; if it went to spam, he won't reply. Two days pass with no answer.

After hearing nothing, what's the chance the email went to spam?

An old friend of yours insists that a folk remedy for insomnia is absolutely useless; in his mind, the chance it works is 0. Later he reads about ten rigorous controlled trials, all showing the remedy works, and there's nothing to fault in the trials themselves. He works it out again using "the odds from the old confidence times the factor from the new evidence."

After the calculation, how sure will he be that the remedy works?