Friday, November 11, 2016

"The Boy Who Cried Wolf" and Bayesian Probability

One of the most famous and well known fables in the world is "The Boy Who Cried Wolf". It was written by Aesop (6th century BCE) as a cautionary tale against false alarms:

"The tale concerns a shepherd boy who repeatedly tricks nearby villagers into thinking wolves are attacking his flock. When one actually does appear and the boy again calls for help, the villagers believe that it is another false alarm and the sheep are eaten by the wolf. In later English-language poetic versions of the fable, the wolf also eats the boy" (from Wikipedia)



It's a simple message, really. If you lie and get caught - people stop believing you. 

Think of your own surroundings. Do you know any "false-alarm boys"?
Maybe it's the co-worker who keeps committing to deadlines but never completes the task in time. Maybe it's the boss who summons you to a 1-on-1 meeting but postpones it time and time again. Maybe it's that friend who has an existential life crisis - twice a week, every week...

What should we do? At which point should we stop trusting them and start assuming every alarm is a false alarm? Or maybe we should be flexible and give them a second (or third) chance?
Bayesian probability might hold the answers.

As humans we must make decisions all the time. When should I leave to get to work in time? Should I go to that meetup? What career should I choose? These decisions force us to (partially) predict the future - based on our beliefs about the world. In order to decide when should you leave for work, you must have some idea of how long is the drive to the office - some knowledge about the surrounding world (often from past experience) that allows you to make a prediction: "the drive usually takes me 30 minutes so I should leave at 8:30". 
Unfortunately, we are unable to predict the future exactly. A more accurate saying would be "on average, the drive takes 30 minutes, but it depends on traffic. Most often it's between 25 and 35 minutes". So there is some probability distribution of drive length - with a mean of 30 and most of it is concentrated between 25 and 35. If we leave at 8:30 we'll often be late due to this uncertainty. Perhaps then we should leave for work at 8:25 so we have a buffer against the common fluctuations?

Let's rephrase these considerations in Bayesian notation. Our goal is to get to work in time - to minimize the chance of being late. We could leave 3 hours ahead of time - thus practically ensuring that we're at the office at 9:00, but that's somewhat extreme and inefficient. Let's say being late once a month is an acceptable rate, so we need to make the probability of being late on each day about 5%, written as: P [ late ] = 5%.
The knowledge about the world that we've accumulated so far - in our example it's our past experience of driving to work many times before - is called the prior probability distribution - or just prior. Let's say that according to our experience the drive takes longer than 35 only 5% of the days, so leaving at 8:25 will satisfy our goal.

Now imagine there's a politician visiting town. Some of the roads are blocked for security purposes, there are many people attending her rally etc. The visit is creating traffic jams around the city - making the drive to the office about 45 to 55 minutes. If we use our normal strategy and leave at 8:25 we actually have a very large probability to be late - the distribution changed because the world changed. This is written as:
P [ late | politician, leave at 8:25] > 5%
Everything after the dividing line is information about the world - in addition to our prior beliefs - which change our predictions about the future. In our case - we should probably leave for work at 8:05 on politician days to preserve the regular probability for being late ( P [ late | politician, leave at 8:05] = P [ late | no politician, leave at 8:25] ).

But what if we don't know whether there's a politician in town or is it a normal day? A political visit is a rare event so on any given day it's reasonable to assume there isn't one. Imagine you leave the house at 8:25, as always, but the met with huge traffic jams - making the drive 50 minute long. You'd probably say "what happened? It never takes so long. Is there a politician in town or something?" - because under your baseline assumptions about the world ("no politician") a 50 minute drive to work is extremely unlikely. You thus deduce that your hypothesis about the state of the world might be wrong. 

Congratulations! You now know the basic ideas behind Bayesian probability: you try to figure out what's more and less likely to happen, according to your existing beliefs about the world - both these probabilities and your beliefs change as new information is discovered. 
Now let's apply these ideas, in a slightly more formal way, to Aesop's fable.

Imagine the villagers whose herd of sheep is guarded by "false-alarm boy". When they hear him "cry wolf", should they believe him? How likely is it that there actually is a wolf?
It depends on what they think about the boy - do they trust him? Is he a trustworthy person? And how should their opinion about him change as new information becomes available?

Humans often think of people as belonging to one of several categories. Let's assume for simplicity 3 archetypical types: "completely honest and trustworthy" (with a small percentage of "no-wolf" because he might make an innocent mistake), "not trustworthy" (his word basically has no meaning - there might be a wolf and might not be, they'll believe it when they see it) and "malicious" (he's probably bullshitting us again - but it might be the one time he's telling the truth).
The villagers are good and honest people so they naturally assume other people are probably honest as well. So before they know anything about the boy they assume there's a 90% probability he's "completely honest", 5% he's "not trustworthy" and 5% he's "malicious".


Probability that the wolf actually existsProbability that there is no wolf
"Completely Honest"99%1%
"Not Trustworthy"50%50%
"Malicious"10%90%

Under these beliefs about the boy, what are the odds there's actually a wolf when the boy raises the alarm?


P [wolf] = P [wolf | boy is honest] * P [boy is honest] +  
                                        P [wolf | boy is untrustworthy] * P [boy is untrustworthy] +  
                              P [wolf | boy is malicious] * P [boy is malicious] = 92% 

So it is highly probable there actually is a wolf - and the villagers should run to check it out.
But there is no wolf. This is new information - an alarm was raised and turned out to be false. Now it seems less likely that the boy is "honest", since a false alarm is a very rare event if he's "honest". How much less likely? 
Bayesian math gives us the answer:  

P [boy is honest | there was no wolf] = 
P [there was no wolf | boy is honest] * P [boy is honest] /
 P [there was no wolf]

I won't go into the math behind it - you can find it here - but the idea is simple: the new probability that the boy is honest (now that we know there was no wolf) is the base probability that the boy is honest (what we used to believe) multiplied by the relation between how likely the new evidence is according to the hypothesis that the boy is honest vs. its general likelihood. So, if some belief about the world predicted an occurrence to be more likely than other beliefs - and that occurrence turned out to be what actually happened - we should now have more faith in that belief about the world.


Using the numbers from above we get:
P [boy is honest | there was no wolf] = 11.4%
Wow. The villagers' trust in the boy is shattered after only a single false alarm. It is now more likely he is malicious or at least untrustworthy:


P [boy is untrustworthy | there was no wolf] = 31.6%
P [boy is malicious | there was no wolf] = 57%

Under these new views about the boy, when he now raises the alarm a second time - how likely is it to be true?
P [wolf] = 33%
Already it's more likely that there is no wolf. But maybe the damage that an undefeated wolf can cause (X) is greater than the pain of dropping everything and running to the fields (Y) - let's say 5 times greater (X = 5Y). The rational thing would still be to go check it out, for the 1/3 chance that the wolf is actually there:


Damage [responding to alarm] < Damage [ignoring alarm]
Y < P [wolf] * X + P [no wolf] * 0
Y < 0.33*5Y

Let's say the villagers indeed follow this logic and believe the alarm for the second time - and it turns out to be false again. The new opinions about the boy are:

P [boy is honest | twice there was no wolf] = 0.17%
P [boy is untrustworthy | twice there was no wolf] = 23.6%
P [boy is malicious | twice there was no wolf] = 76.6%

After 2 false alarms the villagers should be pretty much convinced that the boy is maliciously lying to them. If he raises the alarm a third time, the probability that there really is a wolf would be: P [wolf | twice there was no wolf] = 19.6%.
Even the threat of a rampaging wolf is not enough to convince the villagers to respond, since Damage [responding to alarm] > Damage [ignoring alarm].

Note that true alarms would gradually restore the trust in the boy - but, unfortunately, trust is rebuilt much slower than it is destroyed. Let's say the 3rd alarm - which the villagers probably already ignored - was true. The new opinions about the boy's personality would be:

P [boy is honest | 2 false alarms, 1 true] = 0.86%
P [boy is untrustworthy | 2 false alarms, 1 true] = 60.2%
P [boy is malicious | 2 false alarms, 1 true] = 39%

The boy looks less malicious and more simply untrustworthy - but still highly unlikely to be honest.
Once broken, real trust is hard to rebuild. It's not enough to do the right thing more often than the wrong thing. Every mistake has a substantially higher price than what's gained through honest actions. 
This is something we've all felt ourselves, the "1/2 strikes you're out" approach, and the math seems to support it...

Or does it?

Imagine the boy was actually a different kind of person, from a 4th category that wasn't even in the villagers' minds - we'll call it "good intentioned yet fallible human" - or "human" in short.


Probability that the wolf actually existsProbability that there is no wolf
"Human"90%10%

Unfortunately, the villagers don't have a mental model for such a person. How would their belief change with each "wolf" cry? Using the same calculations as above we can extrapolate the villagers attitude to the "human" boy:

New Evidence"Completely Honest""Not Trustworthy""Malicious"P [False Alarm]
Initial Belief90.00%5.00%5.00%7.90%
TRUE96.74%2.71%0.54%2.81%
TRUE98.55%1.40%0.06%1.73%
TRUE99.28%0.71%0.01%1.35%
FALSE73.37%26.25%0.38%14.20%
TRUE84.66%15.30%0.04%8.54%
TRUE91.63%8.36%0.00%5.10%
TRUE95.59%4.41%0.00%3.16%
TRUE97.72%2.28%0.00%2.11%
TRUE98.84%1.16%0.00%1.57%
TRUE99.41%0.59%0.00%1.29%
FALSE77.10%22.90%0.00%12.22%
TRUE86.96%13.04%0.00%7.39%
TRUE92.96%7.04%0.00%4.45%
TRUE96.32%3.68%0.00%2.81%
TRUE98.10%1.90%0.00%1.93%
TRUE99.03%0.97%0.00%1.47%
TRUE99.51%0.49%0.00%1.24%
FALSE80.23%19.77%0.00%10.69%
TRUE88.93%11.07%0.00%6.42%
TRUE94.09%5.91%0.00%3.90%
TRUE96.92%3.08%0.00%2.51%
TRUE98.42%1.58%0.00%1.77%
TRUE99.20%0.80%0.00%1.39%
TRUE99.59%0.41%0.00%1.20%
TRUE99.79%0.21%0.00%1.10%

Note how the villagers (should) gradually be convinced of the boy's honesty with successive true alarms, but their faith in him drops by 20-25% every time he makes a mistake: 

Thankfully, with every instance of correct behaviour the villagers gradually "forgive" the boy and after 6-7 true alarms he regains their full trust.

This is what the math suggests you should think about the boy in our story - as a rational person. 
Well, do you? 
Can you forgive someone who did the wrong thing once or twice - but made up for it by doing the right thing 10 times? What about 100 times? 
Ever?

Until next time, may you be cautious enough to be safe from "malicious" friends, but generous enough not to lose the "human" ones.


Michael.



{If you find my ideas or analysis interesting - consider subscribing (box on the right). You'll never miss a post and I'll know I'm not talking only to myself :) }