solving probability puzzles with bayes’ nets · this document explains in detail how to give...

53
Solving Probability Puzzles with Bayes’ Nets Solving Probability Puzzles with Bayes’ Nets 1. Introduction 2 Standardising Probability Information 2.1 Basic Probability Tables 2.2 Conditional Probability Tables 2.3 Translating into standard language 2.4 Detection Problems: False Positives and False Negatives 3. Solving Different Examples 3.1: Simple Updating 3.2 Evidence Chain 3.3 Common Cause 3.4 Common Effect 3.5 Causal Triangle 3.6 Compound Problems Appendix 1: Introduction to UnBBayes Appendix 2: Vocabulary of Tests and Sensors

Upload: others

Post on 23-Mar-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes’ Nets

Solving Probability Puzzles with Bayes’ Nets

1. Introduction

2 Standardising Probability Information

2.1 Basic Probability Tables

2.2 Conditional Probability Tables

2.3 Translating into standard language

2.4 Detection Problems: False Positives and False Negatives

3. Solving Different Examples

3.1: Simple Updating

3.2 Evidence Chain

3.3 Common Cause

3.4 Common Effect

3.5 Causal Triangle

3.6 Compound Problems

Appendix 1: Introduction to UnBBayes

Appendix 2: Vocabulary of Tests and Sensors

Page 2: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.2

1. Introduction This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets. In particular, this document will explain how to use software programs like UnBBayes to reach these solutions. It is also possible to calculate numerical solutions using the inbuilt probability calculator on the SWARM platform. There is more information on information about using this calculator in the Help file Solving probability puzzles with the SWARM Calculator .

This most important thing in solving any probability puzzle on the SWARM platform is correctly understanding what are the variables in the problem, and how they are related to each other – which variables affect other variables, and how. This information is best presented in terms of influence diagrams .

A report on the SWARM platform which correctly identifies the logical structure of the puzzle can still be a good report, even if it doesn’t reach the correct numerical solution. However a report which fails to understand the logical structure of the puzzle has little chance of success.

1. Draw an influence diagram. There is more information on influence diagrams in the Help file Drawing Influence (Dependency) Diagrams .

2. Standardize the information . Second, put the probability information you are provided with into a standard format.

a. “Translate” from the way the probabilities were described for you into the language we need in order to apply our methods for solving puzzles; and

b. Lay out the translated information in a standard table format

3. Calculate the answer . The first two steps are really just setting you up for the third, which is calculating the answer(s) to the puzzle. You can do this in a few different ways; the one we recommend, and will illustrate many times below, is to use Bayes net software. This requires the following steps:

a. Create the Bayes net in your software b. Enter the information from the probability tables c. Conduct a sanity check d. Instruct the software to calculate the answer(s).

Updated: March 2018

Page 3: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.3

2 Standardising Probability Information Probabilities are described in lots of different ways. By “standardising” I mean

1. “Translating” from the way the probabilities were described for you into the language we need in order to apply our methods for solving puzzles; and

2. Laying out the translated information in a standard table format

We use tables because the problems you encounter in CREATE are likely to involve events or variables with only a few discrete states ­ usually just two states such as True/False).

Standard table formats

It’ll be easiest if I start by explaining the standard tables.

There are two kinds of tables we’ll need:

1. Basic probability tables 2. Conditional probability tables.

2.1 Basic Probability Tables

These very simple tables just tell us how likely the different states of a variable are “in general”. They are used for variables which ­ in a given probability puzzle ­ are not influenced by any other variable, that is, they are “root” nodes in the influence diagram.

Recall the DNA Match example discussed above. There we were told that the prior probability that Guilt is true (that is, the probability that the suspect is guilty, before we know anything more) is one in 10 million. Here is a basic probability table for this information:

Probabilities for Variable: Guilt

State Probability

True .0000001 (1 in 10 million)

False .9999999

Updated: March 2018

Page 4: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.4

2.2 Conditional Probability Tables

These tell us the probabilities of the states of a dependent variable, for each possible state of the variable it depends on (or, in more complicated cases, for each combination of states of the variables it depends on).

In our example, we were told two things:

1. The DNA test always matches the actual DNA “donor”. That is, if a person is Guilty, they will always be a match; the variable DNAMatch is True with 100% probability.

2. The DNA test has a (low) error rate of one in a million. That is, one in a million people who were not guilty will still return a positive test.

These conditional probabilities are displayed in a table as follows:

Conditional Probabilities for Variable: DNAMatch

State Probability

Guilt = True Guilt = False

True 1 i.e., if the person is guilty, then the probability that DNAMatch is True is 1

0.000001 (1 in a million) i.e., if the person is NOT guilty, then the probability that DNAMatch is true is .000001

False (0) i.e., if the person is guilty, then the probability that DNAMatch is False is 0

(0.999999) i.e., ??

Note that the numbers in the bottom row are in parentheses. This is because we were not told this information directly; rather, we obtained those numbers by calculating them from information we were given, which is in the row above.

Exercise : What would you replace the ?? with in the lower right corner? In other words, how should you interpret the number 0.999999 in the table? (Answer at bottom of next page)

Updated: March 2018

Page 5: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.5

2.3 Translating into standard language

Now comes the trickier part. 1

People describe probabilities in many different ways. They have many different terminologies or “languages” and, worse, they don’t always use their terminology precisely or consistently.

To solve probability puzzles, we need to know exactly what we’re talking about: hence the need to translate into a clear, consistent way of expressing probabilities.

Chance and Odds

In our daily lives, we most commonly refer to chance and odds as if they were the same. “What are the odds?”, we often casually remark. In fact they are equivalent but slightly different ways of representing uncertainties, and you may have to convert. For our purposes, you need to use a single form.

To explain the difference between chance and odds, think of rolling dice. If you roll a six­sided die, you have a one in six chance (or probability) of rolling a 6, because there are six possible outcomes, only one of which will succeed. Well, if the die is fair!

But we can also say that the odds of rolling a 6 are one in five (or 5:1 against) because there are five ways to fail and one way to succeed. The odds are the number of ways to succeed (or the chance of success) divided by the number of ways to fail (or the chance of failure); it’s the ratio of something to its complement.

In mathematical terms, we can express it like this:

, and dds(x) O = Pr(x)1 − Pr(x) r(x) .P = Odds(x)

1 + Odds(x)

1 Answer to exercise on previous page: If the suspect is NOT Guilty, then the probability of No Match is 0.999999.

Updated: March 2018

Page 6: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.6

Chances and Odds in a Standard Probability Table

Both these equivalent expressions:

The chance of a six is 1/6 ≈ 0.17 The odds of a six are 1 in 5, or 5 to 1 against

standardize to this table : 2

Probabilities for Variable: Die

State Probability

Six 0.17

NotSix 0.83

2.4 Detection Problems: False Positives and False Negatives

In many situations, we are be trying to detect or diagnose something. For instance, we may want to

Find a target (such as an enemy tank) Decide which emails are spam Detect cancer cells Work out the Blue­Green cab problem.

We need to consider both the judgment (like “present” or “absent”) and whether it is correct. For binary events, judgments are either positive (that is, the target is present) or negative (that is, the target is absent) and that judgment can be either true or false.

There are four possible combinations of judgment and correctness. Often our attention is drawn only to the correctly identified detections – the true positives and true negatives. However failing to consider the importance of the false positives and false negatives is one of the main reasons why we can go wrong in thinking about probability. The following table shows the vocabulary (with our preferred terms in bold):

2 Again, we will see that you can enter this table as “1” and “5”, and then normalize.

Updated: March 2018

Page 7: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.7

Target Present Target Absent

Say “Present” True Positive (TP)

Hit

False Positive (FP)

False Alarm

Say “Absent” False Negative (FN)

Miss

True Negative (TN)

Correct Rejection

Totals 1 (i.e. 100%)

1 (i.e. 100%)

The columns each total 100% because whichever is the real case, you must say either “Present” or “Absent’. The rows do not have totals because there is no constraint on how often you say one versus the other: if you wanted never to miss a cancer, you could always say “Present”. If you wanted never to have a false alarm, you could always say “Absent”. (This would not be useful, but you could do it.)

When probabilities are expressed in terms of Hit rates, False Alarm rates and so on, they are expressing conditional probabilities . A conditional probability is a probability given some condition; or, put another way, the probability if something else happens or is true. There is a wide range of vocabulary used for these different terms, or combinations of them. A list of this vocabulary, and how to understand it, is given in Appendix 2 of this document.

So, to standardize them, we need to enter them correctly into a conditional probability table . 3

Here’s how to enter test or sensor quality numbers into our standard conditional probability table format:

3 In general, a conditional probability distribution .

Updated: March 2018

Page 8: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.8

Conditional Probabilities for Variable:

State Probability

True False

True True Positive rate or Sensitivity or Hit rate

False Positive rate or 1 ­ Specificity or False alarm rate

False False Negative rate or 1 ­ Sensitivity or Miss rate

True Negative rate or Specificity or Correct Rejection rate

We will give two examples of constructing Conditional Probability Tables.

Example 1

Suppose you are given the following information:

An infrared detection system for missile launches issues a warning when it detects a launch. However, it is not completely accurate. It has a false alarm rate of 15% and a miss rate of 23%.

These rates are conditional probabilities, and the relevant variables are:

Missile , with states Launch or NoLaunch Detection , with states Positive or Negative

Using the table above as our translation manual, we can enter the numbers into a standard conditional probability table as follows:

Updated: March 2018

Page 9: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.9

Conditional Probabilities for Variable: Detection

State Probability

If Missile = Launch (that is, if the Missile variable is in the state Launch)

If Missile = NoLaunch

Positive 15% (false alarm rate)

Negative 23% (miss rate)

To complete the standardization, we need to do two more things: convert to decimals and calculate the missing entries.

Conditional Probabilities for Variable: Detection

State Probability

If Missile = Launch If Missile = No Launch

Positive (0.77) 0.15

Negative 0.23 (0.85)

Note: The calculated values are in parentheses to indicate that they were not provided but have been calculated from the information that was provided.

Technical note: if you’re told the accuracy of a sensor, you can’t (without further information) translate that into numbers in the quadrants. Many different sets of numbers could give you the same overall accuracy figure. (So, if you are told only “80% accurate” you may have to explicitly assume both the hit rate and correct rejection rate are 80%.)

Updated: March 2018

Page 10: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.10

Example 2

Drone software misses 1 in 9 targets and wrongly classifies 20% of friendly tanks.

The variables here are:

Tank ­ Enemy or Friendly Drone ­ Positive or Negative

If we enter this information in a standard table, it will look like this:

Conditional Probabilities for Variable: DroneReport

State Probability

Tank = Enemy Tank = Friendly

Positive (0.89) 0.2 (“wrongly classifies 20% of friendly tanks”)

Negative 0.11 (“misses 1 in 9 targets”)

(0.8)

Updated: March 2018

Page 11: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.11

3. Solving Different Examples If you are able to:

1. Draw Influence Diagrams , and 2. Standardise information into Conditional Probability Tables

Then you are able to solve a wide variety of probability puzzles.

As mentioned earlier, the most important thing in solving these puzzles in understanding the logical structure. In this section we will give detailed examples of how to fully solve the following kinds of puzzles, using software programs like the UnBBayes. More information about this software program is given in Appendix 1 of this document.

2.1 Simple updating

2.2 Evidence Chain

2.3 Common Cause

2.4 Common Effect

2.5 Causal Triangle

2.6 Compound Problem

Updated: March 2018

Page 12: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.12

3.1: Simple Updating

Let’s use what we have learned so far to solve a classic probability puzzle that takes the form of a simple chain, A → B . We will learn about B and need to infer about A .

The Blue Green Cab Problem

A cab was involved in a hit and run accident at night. Two cab companies, Green Cabs and Blue Cabs, operate in the city. 85% of the cabs in the city are in the green livery of Green Cabs and 15% are in the blue livery of Blue Cabs. A witness identified the cab’s livery as blue. The court tested the reliability of the witness under the same circumstances that existed on the night of the accident and concluded that the witness correctly identified each one of the two colours 80% of the time and failed 20% of the time.

What is the probability that the cab involved in the accident was blue (rather than green), knowing that this witness identified it as blue?

We’ll follow the SWARM step­by­step approach.

Step 1: Draw the influence diagram

To set up the problem, first draw the influence diagram. There are two variables:

1. CabColor ­ with states of Green or Blue 2. WitnessReport ­ with states of reports “green” or reports “blue”

The influence diagram is simple:

Updated: March 2018

Page 13: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.13

Step 2: Standardize the information

Second, standardize the probability information. This means taking the information and language from the problem statement, and translating it into an appropriate table.

We’re told “85% of the cabs in the city are in the green livery of Green Cabs and 15% are in the blue livery of Blue Cabs.” This is telling us the probabilities for the variable CabColor , so it goes in a basic probability table:

Probabilities for Variable: CabColor

State Probability

Green 0.85 (“85% of the cabs are green”)

Blue 0.15

Then we’re told that, in testing for reliability, “the witness correctly identified each one of the two colours 80% of the time and failed 20% of the time.” This translates as:

Hits: 80% Correct rejections: 80% False alarms: 20% Misses: 20%

So our conditional probability table looks like this:

Conditional Probabilities for Variable: WitnessReport

State Probability

If CabColor = green If CabColor = blue

Reports “green” 0.8 0.2

Reports “blue” 0.2 0.8

Updated: March 2018

Page 14: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.14

Step 3: Calculate the answer ­ with a Bayes Net

What we want to know is the chance the cab is blue, given that the witness reports it as blue. You may be tempted to say 80% but, remember, even if there were no blue cabs at all, the witness might still report blue. We need a way to combine information about the cab distribution with the report reliability . Neither alone will work. Formally, we are updating our prior belief (that is, only 15% of cabs in the city are blue) given new evidence (that is, the witness report).

Generally, the most straightforward approach is to use Bayes nets, so we’ll use that as our default in all cases, and complement that with other methods from time to time.

Note: Please refer to Appendix 1 Step­by­Step Instructions for Using UnBBayes to solve a simple probability puzzle for more information.

3.2 Evidence Chain

The Simple Updating problem is the most basic of all probability puzzles. I call it Level 1. There are two more levels:

Level 2: Slightly more complicated puzzles. Each of these is another logical lens you should be familiar with.

Level 3: Puzzles which are effectively combinations of Levels 1 and 2.

Evidence Chains

The first Level 2 puzzle type we’ll look at is the evidence chain. Here’s a fairly simple situation:

Michael tells you that Mary, the security guard at the gate, said that she saw the bald man with a weapon. You know that Mary and Michael are quite reliable but not perfectly so.

This is an example of an evidence chain :

Underlying e vent → Report of an event → report of a report of an event

Updated: March 2018

Page 15: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.15

Evidence chains can take many forms, such as

Exposure to a certain chemical may leave a trace. That trace may trigger a sensor alert.

More generally, this pattern is a simple three­link influence chain; the second variable probabilistically depends on the first and the third on the second. For example,

Smoking increases the chance of lung cancer, which increases the chance of early death.

Chains can, of course, be longer than just three links.

Example of an Evidence Chain Probability Puzzle

In a probability puzzle, the conditional probability information you are provided with might take this form:

Evidence Chain Puzzle At this security gate, there is about a 10% chance that a man otherwise similar to the bald man would have a weapon. Mary is a security guard at the gate, and she is good at identifying dangerous individuals. She catches 90% of weapon­carriers (hit rate), though, being cautious, she does incorrectly flag 20% of people who aren’t carrying a weapon. Michael is reporting what he thinks Mary said. If she said “weapon”, Michael is 90% likely to report this accurately. However, due to a hearing loss, he is only 70% likely to correctly relay a “no weapon” judgment: he has a 30% false alarm rate in reporting Mary’s judgment. Given that we have (only) Michael’s report that Mary reported that the bald man had a weapon, what is the probability that the bald man in fact had a weapon?

Updated: March 2018

Page 16: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.16

Step 1: Draw the influence diagram

The influence diagram for this probability puzzle was sketched above, but let's put it into our familiar format. The variables are:

BaldMan ­ with states Weapon and NoWeapon MaryReport ­ with states “Weapon” and “No Weapon” MichaelReport ­ with states “mary reports weapon” and “mary reports no

weapon”

And here are the dependencies:

Step 2: Standardize the information

Standardising the information, we get, for BaldMan :

Probabilities for Variable: BaldMan

State Probability

Weapon 0.1 (“there is about a 10% chance that a man otherwise similar to the bald man would have a weapon”

NoWeapon (0.9)

Updated: March 2018

Page 17: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.17

For MaryReport :

Conditional Probabilities for Variable: MaryReport

State Probability

If BaldMan = Weapon If BaldMan = NoWeapon

“weapon” 0.9 “She catches 90% of weapons­carriers”)

0.2 (“she does incorrectly flag 20% of non­weapons carriers”)

“no weapon” (0.1) (0.8)

and for MichaelReport :

Conditional Probabilities for Variable: MichaelReport

State Probability

If MaryReport = “weapon” If MaryReport = “no weapon”

Mary reports “weapon”

0.9 (“If she said “weapon”, Michael is 90% likely to report this accurately.”)

0.3 (“Michael has a 30% false alarm rate”)

Mary reports “no weapon”

(0.1) (0.7)

Step 3: Calculate the answer ­ with a Bayes Net

Step 3a: Create the Bayes net in your software

If you haven’t done so already, you should create your influence diagram in your Bayes net software; in this case, we are using UnBBayes:

Updated: March 2018

Page 18: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.18

Step 3b: Enter the information

Enter the data from the tables above into the corresponding tables in UnBBayes : 4

BaldMan :

MaryReport :

4 Review the tutorial in the appendix if you need reminders about which icon to press to add states, etc. UnBBayes is simple once you get used to it, but several steps are not obvious the first time.

Updated: March 2018

Page 19: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.19

MichaelReport :

Step 3c: Sanity Check

Compile the Bayes net by clicking on the Compile Bayesian Network icon . After manually adjusting the spacing, you should have a diagram that looks like this:

Now we can see what happens when we set the value of one or more variables.

Suppose, for example, the bald man definitely did have a weapon. Click on the

“weapon” row of the first box, and click on the Propagate Evidence icon . You will see:

This means that if the bald man had a weapon, there is a 90% chance Mary will report this correctly, and an 84% chance that Michael will do so.

Click on the Reset beliefs icon to reset.

Updated: March 2018

Page 20: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.20

Step 3d: Instruct the software to calculate the answer(s)

The probability puzzle was asking us to propagate evidence in the reverse direction. Given that Michael reported that Mary reported that the bald man had a weapon, what’s the chance he actually did?

Click on the upper row of the michael_report box. You should get:

Click on the Propagate Evidence icon , which should result in:

It turns out that Michael’s report only increases the probability the bald man had a weapon by a modest amount: our belief went from 10% to 18%.

This probably surprising result is due to the compounding effect of the unreliability of Michael and Mary.

Updated: March 2018

Page 21: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.21

3.3 Common Cause

By “common cause” we mean “shared cause” rather than “everyday humdrum cause”. A “common cause” happens when two or more events depend directly on a third. For example, if we had multiple witness reports on a taxi cab, the cab is the common cause:

Cases of spurious correlation are often due to an unmentioned common cause. For example, crime rates and ice cream sales both peak during summer months, but it is implausible that either causes the other. It is far more likely that they share a common cause, such as hot weather.

Common cause is different from an evidence chain. In a chain, each step weakens the evidence, because the sensor (witness) is reporting hearsay. Noise accumulates. In a common cause, each sensor (witness) reports directly on the cause. Noise attenuates. That can be very powerful, if the sensors are truly independent. (Common cause is also called a “Naive Bayes” model, because we “naively” assume the sensors are all independent. This is rarely true, but if the sensors are reasonably independent, the model works surprisingly well.)

Example of a Common Cause Probability Puzzle

We extend the earlier one­report puzzle to have two independent reports. So:

The Two­Witness Blue Green Cab Problem

A cab was involved in a hit and run accident at night. Two cab companies, the Green and the Blue, operate in the city. 85% of the cabs in the city are Green Cabs and 15% are Blue Cabs. Two witnesses identified the cab as blue. The court tested the

Updated: March 2018

Page 22: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.22

reliability of the witnesses under the same circumstances that existed on the night of the accident:

Sarah correctly identified each one of the two colours 80% of the time and failed 20% of the time.

Sam correctly identified green 80% of the time and correctly identified blue 60% of the time. (Failing 20% and 40%, respectively.)

What is the probability that the cab involved in the accident was blue (rather than green), knowing that the witnesses identified it as blue?

Suppose Sarah said blue and Sam green, or vice versa?

Step 1 ­ Draw the influence diagram

The variables in the problem are:

CabColor ­ with states Green and Blue Sarah ­ with states Reports “green” and Reports “blue” Sam ­ also with states Reports “green” and Reports “blue”

Both Sarah and Sam are influenced by CabColor (but not vice versa) so the influence diagram looks like this:

Updated: March 2018

Page 23: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.23

Step 2 ­ Standardize the information

As in the original (Level 1) problem, we were told that two cab companies, the Green and the Blue, operate in the city. 85% of the cabs in the city are Green Cabs and 15% are Blue Cabs. This gives us a simple probability table:

Probabilities for Variable: CabColor

State Probability

Blue 0.15

Green 0.85

We were told that Sarah correctly identified each one of the two colours 80% of the time and failed 20% of the time. The conditional probability table for this looks like this:

Conditional Probabilities for Variable: Sarah

State Probability

If CabColor = blue If CabColor = green

Reports “blue” 0.8 0.2

Reports “green”

0.2 0.8

Similarly, we were told that Sam correctly identified green 80% of the time and correctly identified blue 60% of the time. (Failing 20% and 40%, respectively.)

Conditional Probabilities for Variable: Sam

State Probability

If CabColor = blue If CabColor = green

Reports “blue” 0.6 0.2

Reports “green” 0.4 0.8

Updated: March 2018

Page 24: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.24

Step 3: Calculate the answer ­ with a Bayes Net

Step 3a: Create the Bayes net in your software

If we haven’t done so already, we create the influence diagram in UnBBayes:

Step 3b ­ enter the information from the probability tables

Then, selecting each variable in turn, we enter the information from the tables in Step 2:

CabColor Sarah Sam

Step 3c ­ Sanity check

Compile the Bayes net by clicking on the Compile Bayesian Network icon , manually adjust the spacing and you should have a diagram looking like this:

Updated: March 2018

Page 25: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.25

Set the Cab to Blue and click on the Propagate Evidence icon to get:

That matches what we expect. Do the same for Green and, if it checks out, then proceed. If it doesn’t check out, fix the tables before proceeding.

Step 3d ­ Get the Answers

We get our answers by setting the states of some (one or more) of the variables, and reading off the probability for other variables.

In this case, we are interested in the probability that CabColor is Green, or Blue, depending on what we’ve set Sarah and Sam to.

Both say blue

Clear the evidence, and set both reports to “blue” to get our first answer, 68%:

Updated: March 2018

Page 26: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.26

When both witnesses report “blue”, then our belief the cab is Blue rises from the base rate of 15% to 68% or about ⅔. This meets the “preponderance of evidence” standard for a civil case, but not the “beyond a reasonable doubt” standard for a criminal case. 5

Suppose the witnesses disagreed?

Sarah says blue, Sam says green

Changing Sam’s report and re­propagating, our belief is only 26% (about ¼) that the cab is Blue:

Sarah says green, Sam says blue

Reversing the reports and re­propagating, the net effect is to slightly decrease our belief the cab is Blue, to about 12%, because Sarah is more reliable than Sam:

5 Although probabilities are rarely used explicitly in court proceedings, informally the civil standard of “preponderance of evidence” is taken to be “above 50%”, or at least any degree higher than the evidence for the opposing case. The criminal requirement of “beyond a reasonable doubt” is thought to be at least 90% and maybe at least 99%.

Updated: March 2018

Page 27: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.27

Both say green

For completeness, we can check the result if both say green.

As expected, this reduces the chance of Blue to about 2%, so our 98% belief the cab is Green may be high enough to meet the criminal court standard of “beyond reasonable doubt”.

We have considered evidence chains and common causes. Later, we will consider what happens if the reports on a common cause are also dependent on each other.

But first, consider the slightly simpler case of common effect.

Updated: March 2018

Page 28: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.28

3.4 Common Effect

Necessary Causes

In the case of a fire, several things must be present for an effect:

We could model this as a Bayes net but, in its deterministic form, we do not need software to help us. Of course, if Oxygen, Heat and Fuel came in grades, then, so long as none are zero, increasing each might increase the chance of a Fire. They might interact in complicated ways, so let’s start with a simple case.

Redundant Paths

Many systems have multiple ways to bring about an effect. Examples include:

Redundant systems such as battery backups Multiple message paths, any of which suffices Multiple arguments for a conclusion.

The probability of the effect depends on the states of, and dependency on, multiple variables.

We can use Bayes nets to calculate the probability of the effect but it takes a bit more setting up.

Updated: March 2018

Page 29: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.29

Example

Consider this simple model of a computer’s battery backup:

For this example, we suppose both Mains power and Battery are on 90% of the time, and are causally independent of each other. The computer is definitely on if either power source is on.

Our three variables are:

Mains ­ on or off Battery ­ on or off Computer ­ on or off

For mains and battery, which don’t depend on anything else in this situation, we just need simple probability tables:

Probabilities for Variable: Mains

State Probability

On 0.9

Off 0.1

Probabilities for Variable: Battery

State Probability

On 0.9

Off 0.1

To standardise the probability information about the computer, we need a more complex conditional probability table than we’ve seen previously. Since whether the computer is

Updated: March 2018

Page 30: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.30

on depends on both the mains and the battery, our conditional probability table needs to consider the full range of possibilities:

Conditional Probabilities for Variable: Computer

State Probability

Mains On Mains On Mains Off Mains Off

Battery On Battery Off Battery On Battery Off

On 1 1 1 0

Off 0 0 0 1

Having created this conditional probability table, we can copy the values directly into an UnBBayes model:

Main Battery Computer

Compiling the network, we immediately see that two 90% reliable sources make the system 99% reliable ­­ as we might expect.

Because we have modeled the computer deterministically, the inferences are fairly straightforward but they illustrate the effect of multiple paths.

Updated: March 2018

Page 31: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.31

Coin­Toss Models: Binomial and Noisy­OR

Suppose we flip several coins and win if any are Heads. It would be tedious to enumerate all the ways to get at least one Head and then add their probabilities. Fortunately, there is an easier way: the chance of getting any Heads is one minus the chance they are all Tails. But the probability they are all tails is just ½ * ½ * ... = (½) N for N fair coins. So:

Pr(≥1 Head) = 1 ­ Pr(All Tails) = 1 ­ (½) N

This is a very handy special case of the Binomial Theorem: we only need one probability!

But we are rarely concerned with identical coins. Suppose our coins each have a different chance for landing heads. Then the more general form is:

Pr(≥1 Head) = 1 ­ Product(each coin’s chance of Tails )

This is the Noisy­OR model: each coin is still independent but the coins could all have different biases. Now we need one number per cause (so N for N causes). This is still a huge savings from the general case, where N causes need 2 N numbers (say, 10 vs 1,024, or 20 vs roughly 1 million).

We are rarely concerned with coins but many events follow this model. For example, the Battery Backup example is a Noisy­OR: the Computer will be On if some power supply is on, which is one minus the product of the chances each one has failed:

Pr(On) = 1 ­ (Pr(mains fails) * Pr(battery fails))

= 1 ­ (.1 * .1)

= .99

This is also a Binomial example, because the failure rates are the same. But if we are in a situation of rolling blackouts, then Mains power might fail 50% of the time. Then we would have:

Pr(On) = 1 ­ (.5 * .1)

=.95

Now we’re failing an hour a day instead of once per work week.

Updated: March 2018

Page 32: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.32

With only two causes, there is little savings from the Noisy­OR model. But, if there are many causes, it can simplify your life. First, recognizing a Noisy­OR situation lets you model things without software. Second, Noisy­OR can save tedium in making probability tables. For example, Netica has an equation facility where you can specify a Noisy­OR (and many other functions) and let Netica fill in the rest of the table for you. (Unfortunately, UnBBayes does not, so you may have to break out a spreadsheet or script.)

Back to the example, if mains power is out 50% of the time, it might become hard to fully charge the battery backup, so perhaps it is only available 70% of the time. If we are happy with those numbers, then we just change the numbers in our model, so:

Pr(On) = 1 ­ (.5 * .3) = .85.

Now we are failing one hour out of eight. But how can we model dependence among our causes or effects?

3.5 Causal Triangle

Earlier, we imagined the Taxi Cab problem where Witness 2 checked with Witness 1 before reporting. That creates a triangular influence graph, which is causal if each arrow is causal and the arrows do not form a cycle:

The idea was that Witness 2 would tend to revise his report towards Witness 1’s. Capturing that influence helps prevent overconfidence: our model knows they tend to succeed or fail together.

Updated: March 2018

Page 33: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.33

But I’d like to switch to a (fake) medical example. Suppose we know that smoking causes lung cancer, primarily via tar in the lungs, but also by some other mechanisms, and we would like to model that. Then we would have this influence diagram:

Making up some numbers, we say:

20% of the population smokes. Tar is in 80% of smoker’s lungs and 5% of non­smoker’s lungs. Cancer risk is 5% with neither, 10% with either and 30% with both.

Smoking Tar Cancer

Next, we will progressively set Smoking and Tar , so you can see the progression of evidence:

In this population, the cancer base rate is about 9%:

Updated: March 2018

Page 34: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.34

Smokers nearly treble the risk, to 26%. In addition, 80% of them have Tar.

Confirming Tar is present further raises the chance of cancer to 30%, per table:

Updated: March 2018

Page 35: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.35

Cancer is a common effect and so its table specifies how Smoking and Tar combine to cause Cancer . Here, they interact to produce more risk than would be expected from a Noisy­OR or coin­toss model.

However triangles need not force interaction: we could still use a Noisy­OR function in the Cancer node. What they do enforce is multiple paths . Here, Smoking causes Tar along two paths: it directly raises the chance of Cancer (by some non­Tar mechanism), and it raises the chance of Tar , which itself raises the chance of Cancer .

Updated: March 2018

Page 36: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.36

3.6 Compound Problems Many CREATE puzzles present some combination of the basic patterns. A typical compound problem might have multiple reports (common cause), multiple causes (common effect), correlated properties (common cause + chain), and interacting effects (causal triangle) in some combination.

Example: Detecting Firefox Here is an example of a medium­complexity probability puzzle:

In the ( mediocre ) 1982 movie “Firefox” (based on the decent 1977 thriller), US pilot Mitchell Gant steals the Firefox, a fictional top secret supersonic stealth aircraft developed by the Soviet Union. He initially heads south ensuring he is seen by a commercial airliner before using the stealth properties of the plane to turn north unseen. His plan is to follow the Ural mountains to a clever refueling rendezvous before heading west. Here is our adaptation. 6

Imagine you are the Soviet general in charge of the northern defenses. You know Gant was last seen heading south. However, your top analyst says Gant is trained in evasion, and suspects it was a diversion. (We depart from the movie a bit to make an interesting but tractable decision problem.)

Location and Height: You judge there is a 50% chance Gant went north (into your area), probably following the Ural mountains. Your team estimates it is three times as likely he is flying at low altitude than at high (i.e. odds are 3:1 in favor of low).

You have two detection systems.

Acoustic detectors , known as “Big Ears.” These can detect a supersonic aircraft by picking up the sonic boom. The Big Ears detect 95% of low­altitude supersonic targets, and 50% of high­altitude targets. It is unlikely any other aircraft would set them off right now, so there is only a 1% background false alarm rate.

Radar . You know this radar works poorly against a target like Firefox. At best it has a 30% detection, when Firefox is up high presenting a broad target on a clear

6 Extended plot summary and book review by Graeme Shimmin here . Spoiler warning.

Updated: March 2018

Page 37: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.37

background. At low altitudes, detection is only 10%. There is always a 5% false alarm rate, including both system noise, other aircraft, and occasional bird flocks.

System: The sensors are been linked by a simple rules­based system made for detecting possible NATO stealth test flights in the north (the south is someone else’s problem):

1. If Radar reports no contact, and BigEars report a supersonic footprint, say “Stealth”.

2. Otherwise, say “No Stealth”. Your top analyst warns that this system was not designed for stealth as good as Firefox. There is little time to recalibrate for its overly conservative rules, so she intuitively adjusts:

If the system says “Stealth” she will say “Firefox”. Else if the radar reports a contact, she will most likely (75%) say that it is

“Firefox.” Otherwise, she is only 20% likely to say “Firefox”.

Question 1

Your analyst says “Not Firefox”. What is the chance Gant was nevertheless in the north? Compare that with taking a “No Stealth” reading straight from the rules system?

Question 2

Gant knows he is taking the northern route. Which altitude would minimize his chance of being detected?

Step 1: Draw the influence diagram

How do these influence or depend on each other?

There is a complex web of influences among these variables. However I’ll show here how a complex influence diagram is simply built up out of the simpler structures described earlier in this tutorial.

Updated: March 2018

Page 38: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.38

Step 1a: Identify the variables involved in the problem

The variables are:

Variable States Description

Location North, South The most important variable is whether Firefox is in the north or the south.

Altitude Low, High Firefox may be flying low, or high.

BigEars Supersonic, Nil The Big Ears system may report a supersonic footprint.

Radar Contact, Nil The radar system may report the presence of a plane.

System Stealth, No Stealth The system may report whether there is a stealth plane present or not.

Analyst Firefox, Not Firefox The analyst may report that Firefox is present, or not present.

Step 1b: Create a diagram node for every variable

Step 1c: Find the root nodes

Firefox’s path (north or south) and altitude is simply a matter of what Gant decides to do; it doesn’t depend on the state of any of the other variables. So Location and Altitude are root nodes.

Updated: March 2018

Page 39: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.39

Step 1d: Draw arrows from root variables (layer 1) to the variables they influence (layer 2)

If Firefox is in the north (i.e., Location = North) then both BigEars and Radar are more likely to report a plane. So there is a common effect structure here:

Similarly, Altitude affects both BigEars and Radar ­ another common effect structure:

Updated: March 2018

Page 40: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.40

Notice that whether BigEars reports a supersonic footprint or not depends on whether or not Firefox is present (i.e, Location ) and its height ( Altitude ). So this is a common effect structure.

Similarly, Radar depends on both Location and Altitude ­ another common effect structure.

These can all be displayed at the same time in the one diagram:

Step 1e: Repeat until all influences are represented

You can probably see how this continues. By design, System is a common effect of both BigEars and Radar :

Updated: March 2018

Page 41: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.41

The analyst likewise bases her decision on the sensors:

So now we have a complete influence diagram. With the diagram, you can see at a glance how the variables relate, even in a complex situation like this.

Step 2: Standardize the information

Now we need to get our probability information in order. We do this by translating the information into a standard table format.

First, the easiest part ­ the root nodes, Location and Altitude . We were told that there is a 50% chance Firefox is in the north:

Probabilities for Variable: Location

State Probability

North 0.5

South 0.5

Updated: March 2018

Page 42: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.42

And we were told the analysts estimated a 3 to 1 chance Firefox is flying at low altitude. Using our little formula for converting from odds to probabilities, we get 3/(3+1) = 0.75 as the probability for Low, and by similar math 0.25 as the probability for High:

Probabilities for Variable: Altitude

State Probability

High 0.25

Low 0.75

Now we need to look at variables which depend on other variables. These require more complex probability tables. Let’s look at BigEars . We were told:

BigEars can detect a supersonic aircraft by picking up the sonic boom.... The Big Ears detect 95% of low­altitude supersonic targets, and 50% of high­altitude targets. It is unlikely any other aircraft would set them off right now, so there is only a 1% background false alarm rate.

So 95% of the time when there is a low altitude supersonic aircraft in the north, BigEars reports “Supersonic” (i.e. true positive); and so by simple calculation 5% of the time, BigEars will report Nil (false negative).

Similarly, 50% of the time when there is a high­altitude target, BigEars reports “Supersonic” (i.e. true positive); and so 50% of the time, BigEars will report Nil (false negative).

So we can fill in our first two columns:

Conditional Probabilities for Variable: BigEars

State Probability

Location North Location South

Altitude Low Altitude High Altitude Low Altitude High

Supersonic 0.95 0.5

Nil (0.05) (0.5)

Updated: March 2018

Page 43: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.43

When there is no target in the north, i.e. Firefox is in the South, then there is a 1% chance of a “Supersonic” report (false positive), and by simple calculation a 99% chance of a Nil report (true negative). So we can complete our table:

Conditional Probabilities for Variable: BigEars

State Probability

Location North Location South

Altitude Low Altitude High Altitude Low Altitude High

Supersonic 0.95 0.5 0.01 0.01

Nil (0.05) (0.5) (0.99) (0.99)

About Radar , we were told:

At best it has a 30% detection, when Firefox is up high presenting a broad target on a clear background. At low altitudes, detection is only 10%. There is always a 5% false alarm rate, including both system noise, other aircraft, and occasional bird flocks.

“30% detection” means that Radar will report “Contact” 30% of the time when there is an aircraft like Firefox present at high altitude; and only 10% at low altitude. The 5% false alarm rate applies when Firefox is not present at all. So we get this table:

Conditional Probabilities for Variable: Radar

State Probability

Location North Location South

Altitude Low Altitude High Altitude Low Altitude High

Contact 0.3 0.1 0.05 0.05

Nil (0.7) (0.9) (0.95) (0.95)

What about System ? As I mentioned above, this is a bit more complicated because System has three possible states; and it depends on both BigEars and Radar, according to the following rules:

Updated: March 2018

Page 44: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.44

1. If Radar reports a contact, say “Regular Plane”, 2. Otherwise, if BigEars report a supersonic footprint, say “Stealth Plane” 3. Otherwise, say “None”

The table for System is a deterministic function of BigEars and Radar, so what goes into the cells are just ones and zeros.

Conditional Probabilities for Variable: System

State Probability

BigEars Supersonic BigEars Nil

Radar Contact Radar Nil Radar Contact Radar Nil

No Stealth 1 0 1 0

Stealth 0 1 0 1

Note that each column adds up to 1.

Finally, Analyst . We were told:

If the system says “Stealth Plane” she will say “Firefox”. Else if the radar reports a contact, she will mostly likely (75%) say that it is

Firefox. Else she is only 20% likely to say Firefox.

Conditional Probabilities for Variable: Analyst

State Probability

BigEars Supersonic BigEars Nil

Radar Contact Radar Nil Radar Contact Radar Nil

Firefox .75 1 .75 .2

Not Firefox .25 0 .25 .8

Updated: March 2018

Page 45: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.45

Conditional Probabilities for Variable: Analyst

State Probability

System = Stealth Plane

System = Regular Plane

System = None

Firefox 1 0.75 0.2

No Firefox (0) (0.25) (0.8)

Step 3: Calculate the Answer ­ with a Bayes net

Phew! That took a lot of setting up. But we’re now ready to solve the problem. There are various ways to do this, but as usual we’ll do it by just plugging our diagram and numbers into our chosen Bayes net software, UnBBayes.

Step 3a: Create the Bayes net in your software

In fact, I’ve already been doing this; that’s where I created the influence diagram shown above.

Step 3b: Enter the information from the probability tables

This is tedious but straightforward, though you need to be very careful to avoid simple errors.

Here is how it looks for the first variable, Location :

Updated: March 2018

Page 46: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.46

And for System :

To save space I will not display the others here, but you can see how they would go.

Step 3c: Sanity Check

Compile the Bayes net, do some re­arranging, and you get this:

This tells us that, given our baseline probabilities Gant’s flight route (i.e. the values for Location and Altitude ) there is an almost even chance that the analyst will report that Firefox is present. This seems reasonable enough (our sanity check!).

Step 3d ­ Get the Answers

Question 1

Here we set the Analyst report to Not FireFox. What we want to know is the probability that Location is North. Fortunately the UnBBayes software will calculate that number for us:

Updated: March 2018

Page 47: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.47

So this tells us that, when the analyst says Firefox is not present, there is still a 15% chance that Firefox is in the north.

Question 2

Recall that Question 2 was:

Gant knows he is taking the northern route. Which altitude would minimize his chance of being detected?

Since we’ve got everything set up in Bayes Net software, answering this is simplicity itself.

First, reset the net:

Then, see what the probability of Analyst reporting “Firefox” is when taking a high altitude route, by setting Location to North, and Altitude to High, and propagating the evidence:

Updated: March 2018

Page 48: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.48

The probability that the analyst will report “Firefox” is 64%.

Then, see what happens when Altitude is set to Low:

The probability is now 94%! Gant is far better off taking the high altitude route.

Updated: March 2018

Page 49: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.49

Appendix 1: Introduction to UnBBayes Several Bayes net packages offer robust systems to do quite complicated probability calculations using influence graphs. For an investment of 15­30 minutes to install and learn the basics, you should be able to tackle all the problems you will face in SWARM. We recommend one of the following four packages:

Netica (Windows, Free trial for small networks) UnBBayes (Java, Free Open Source) GeNiE (30­day trial, free for academic use) Tetrad (Java, Free Open Source)

Of these, Netica is probably the easiest to learn and use, but only runs natively on Windows machines. Therefore, we will use UnBBayes here. You should have little difficulty translating what you learn to Netica. 7

Installing UnBBayes

If you have trouble launching UnBBayes or following along, please view the 10­minute UnBBayes “ Bayes net tutorial ” video.

1. Launch UnBBayes by double­clicking: a. unbbayes­4.22.18 Executable Jar File or, b. If (a) fails, use the GUI or command­line to run either:

i. unbbayes.bat (for Windows), or ii. unbbayes.sh (for Mac or Linux).

c. Note that you need a Java runtime for this to work.

2. Click the “BN” icon to open a blank network.

Step­by­Step Instructions for Using UnBBayes to solve a simple probability puzzle

1. Create and link two new variables using two of these tools:

7 GeNiE and especially Tetrad are more focused on learning models from data, and possibly harder to use for straight modeling. Other notable packages include Bayesia Labs and SamIam.

Updated: March 2018

Page 50: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.50

a. Click on the “D” icon ( ), then click in the workspace to create the first variable.

b. Repeat the step above to create the second variable.

c. Select the arc icon , then draw an arc from C1 to C2.

Your screen should now look like this:

2. Edit the C1 variable by doing the following: a. Click on the C1 variable. b. In the Name field, type “Cab” then press the Enter key to apply the

change. c. In the Description field, type in a description then press the Enter key.

d. Click on the + icon to add a second state. e. Click on the State 0 field and type “Blue”. f. Click on (or tab to) the Probability field and type “.15” g. Click on (or tab to) the State 1 field and type “Green”. h. Click on (or tab to) the Probability field and type “.85”

Note: Do not click on the Apply button until after you have edited the C2 variable, lest it undo your work.

Updated: March 2018

Page 51: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.51

3. Edit the C2 variable by doing the following: a. Click on the C2 variable. b. In the Name field, type “Witness” then press the Enter key to apply the

change. c. In the Description field, type “Witness Report” then press the Enter key.

d. Click on the + icon to add a second state. e. Click in the State 0 field and type “blue”. f. Click in (or tab to) the Blue column and type “.8” g. Click in (or tab to) the Green column and type “.2” h. Click in (or tab to) the State 1 field and type “green”. i. Click in (or tab to) the Blue column and type “.2” j. Click in (or tab to) the Green column and type “.8”

4. Save the Bayes net by selecting File / Save from the top menu bar. 5. In the Save dialog box, type “cab” in the File Name field. 6. Select the Net option in the Files of Type field, then click on the Save button. 7. Click the OK button on the Success pop­up window.

8. Select the Compile Bayesian Network icon to compile your Bayes net. Your screen should now look like this. Note: You may have to drag a node cross if they overlap.

Updated: March 2018

Page 52: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.52

9. Click in the blue field in the Witness table to set it to 100% (to show that the witness said the cab was blue).

10.Click on the Propagate Evidence icon .

The probability that the cab was blue is now displayed as 41.38% (rounded down to 41%):

11. To try other scenarios, click on the Reset Beliefs icon , then click on the

Return to Edit Mode icon to try different values before clicking again on the

Propagate Evidence icon .

Updated: March 2018

Page 53: Solving Probability Puzzles with Bayes’ Nets · This document explains in detail how to give complete solutions to probability puzzles using the technique known as Bayes’ Nets

Solving Probability Puzzles with Bayes Nets p.53

Appendix 2: Vocabulary of Tests and Sensors When describing test or sensor quality, you will often see terms such as:

Accuracy Sensitivity Specificity Hit rate Miss Rate False alarm rate.

Here is what these mean:

Term Meaning Calculation

Accuracy Number correct out of total total##correct = total#

TP+TN

Sensitivity Hit rate

The proportion of the positive cases which were classified as such (true positive rate)

#hits#present =

TPTP+FN

1 ­ Sensitivity Miss rate

The proportion of the positive cases which were classified as negative (false negative rate)

#miss#present =

FNTP+FN

Specificity Correct Rejection rate

The proportion of the negative cases which were classified as negative (true negative rate)

#absent#reject. = TN

TN+FP

1 ­ Specificity False Alarm Rate

The proportion of the negative cases which were classified as positive (false positive rate)

#absent#false alarms = FP

TN+FP

Updated: March 2018