session 7 bayesian networks i - dtai...0.7 p(¬b|a)= 0.3 f ? p(¬b|¬a) = 0.9 probability and...

75
Session 7 Bayesian Networks I Solutions

Upload: others

Post on 25-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Session 7Bayesian Networks I

Solutions

Page 2: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Conditional Probability

Page 3: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Conditional probabilityProbability of event happening given that other event happened

Normalization

Page 4: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Exercise 1: aNormalize the following table so that it represents the conditional probability P(A|B)

Note that A is a binary variable with domain {1, 2} andB a ternary variable with domain {true, false, maybe}

Page 5: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Solution

P(A|B) B

true false maybe

A1 0.1/(0.1+0.5) = 1/6 0.5/(0.5+0.2) = 5/7 0.3/(0.3+0.3) = 1/2

2 0.5/(0.1+0.5) = 5/6 0.2/(0.5+0.2) = 2/7 0.3/(0.3+0.3) = 1/2

Page 6: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Exercise 1: bDo the same for the following tables.

The variables A,B and C have the domain {true, false}

Page 7: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Solution

P(A,B|C=true) B

true false

Atrue 0.3/1.3 = 3/13 0.5/1.3 = 5/13

false 0.2/1.3 = 2/13 0.3/1.3 = 3/13

N = 0.3 + 0.5 + 0.2 + 0.3 = 1.3

P(A,B|C=false) B

true false

Atrue 0.2/0.6 = 1/3 0.1/0.6 = 1/6

false 0.2/0.6 = 1/3 0.1/0.6 = 1/6

N = 0.2 + 0.1 + 0.2 + 0.1 = 0.6

Page 8: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Independence

Page 9: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Exercise 2

Page 10: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

IndependenceP(A,B) = P(A) P(B) must hold

Two methods:

● Naive● Ratio Trick

Page 11: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Independence: Naïve methodNotice that:

Which can be solved to yield:

Analogously: P(A=2, B=maybe) = 0.2

Page 12: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Independence: Naïve methodSimilarly, for the second exercise

Page 13: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Independence: Ratio trickWe can really exploit what it exactly means that A and B are independent of each other. For example: learning something about B shouldn't give us any new information about A. In other words, given that we know one of the values P(A = 1, B) or P(A = 2, B) for a given B, we don't need to know the actual value of B in order to compute the other one. This can happen in the following two cases.

1. The value that we know is 1. This entails that all other values in the table are 0. In our exercise, this doesn't hold.

2. The ratio between P(A = 1; B = b) and P(A = 2; B = b) is equal for all b.

Page 14: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Independence: Ratio trickThis can easily be shown by exploiting the independence relation, as

It is now a piece of cake to compute the missing values

Page 15: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Independence: Ratio trickWe can again use the fact that for different instantiations of a the quotient of the joint probabilities is a constant:

Page 16: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Independence: Ratio trick

P(A,B) B

true false maybe

A1 0.05 0.1 0.15

2 0.05 x 2.33 0.1 x 2.33 0.15 x 2.33

Page 17: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Conditional Independence

Page 18: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Exercise 3

Page 19: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Conditional IndependenceAlso use ratio trick. However, due to conditional independence, ratio trick only works for a given C. This means that we handle the two tables separately.

Page 20: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Conditional Independence

P(A,B,c=true) B

true false

A

x 0.056 0.084

y 0.08 0.012

z 0.016 0.024

P(A,B,c=false) B

true false

A

x 0.072 0.008

y 0.432 0.048

z 0.216 0.024

Page 21: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability & Bayes’ Rule

Page 22: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability and Bayes’ RuleIn Leuven 80% of all cars are red. You see a car at night that does not appear red to you. You know that you correctly identify a red car in only 70% of the cases, while you can identify a non-red car correctly in 90% of the cases.

Page 23: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability and Bayes’ Rule

In Leuven 80% of all cars are red. You see a car at night that does not appear red to you. You know that you correctly identify a red car in only 70% of the cases, while you can identify a non-red car correctly in 90% of the cases.

1. List all conditional and non-conditional probabilities that you can determine directly from the task description.

2. Compute the probability that the car is actually red, when you perceive a car as red in Leuven at night.

Page 24: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability and Bayes’ Rule

In Leuven 80% of all cars are red. You see a car at night that does not appear red to you. You know that you correctly identify a red car in only 70% of the cases, while you can identify a non-red car correctly in 90% of the cases.

1. List all conditional and non-conditional probabilities that you can determine directly from the task description.

Page 25: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability and Bayes’ Rule

In Leuven 80% of all cars are red. You see a car at night that does not appear red to you. You know that you correctly identify a red car in only 70% of the cases, while you can identify a non-red car correctly in 90% of the cases.

Page 26: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability and Bayes’ Rule

In Leuven 80% of all cars are red. You see a car at night that does not appear red to you. You know that you correctly identify a red car in only 70% of the cases, while you can identify a non-red car correctly in 90% of the cases.

A: A car is red

T F

P(A) = 0.8 ?

Page 27: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability and Bayes’ Rule

In Leuven 80% of all cars are red. You see a car at night that does not appear red to you. You know that you correctly identify a red car in only 70% of the cases, while you can identify a non-red car correctly in 90% of the cases.

A: A car is red

T F

P(a) = 0.8 P(¬a) = 0.2 Indirect knowledge!

Page 28: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability and Bayes’ Rule

In Leuven 80% of all cars are red. You see a car at night that does not appear red to you. You know that you correctly identify a red car in only 70% of the cases, while you can identify a non-red car correctly in 90% of the cases.

Page 29: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability and Bayes’ Rule

In Leuven 80% of all cars are red. You see a car at night that does not appear red to you. You know that you correctly identify a red car in only 70% of the cases, while you can identify a non-red car correctly in 90% of the cases.

B: A car is perceived to be red

T F

? ?

Page 30: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability and Bayes’ Rule

In Leuven 80% of all cars are red. You see a car at night that does not appear red to you. You know that you correctly identify a red car in only 70% of the cases, while you can identify a non-red car correctly in 90% of the cases.

Page 31: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability and Bayes’ Rule

In Leuven 80% of all cars are red. You see a car at night that does not appear red to you. You know that you correctly identify a red car in only 70% of the cases, while you can identify a non-red car correctly in 90% of the cases.

P(B|A) B: A car is perceived to be red

A: A car is red

T F

T P(b|a) = 0.7

?

F ? ?

Page 32: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability and Bayes’ Rule

In Leuven 80% of all cars are red. You see a car at night that does not appear red to you. You know that you correctly identify a red car in only 70% of the cases, while you can identify a non-red car correctly in 90% of the cases.

P(B|A) B: A car is perceived to be red

A: A car is red

T F

T P(b|a) = 0.7

P(¬b|a)=0.3

F ? ?

Page 33: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability and Bayes’ Rule

In Leuven 80% of all cars are red. You see a car at night that does not appear red to you. You know that you correctly identify a red car in only 70% of the cases, while you can identify a non-red car correctly in 90% of the cases.

P(B|A) B: A car is perceived to be red

A: A car is red

T F

T P(b|a) = 0.7

P(¬b|a)=0.3

F ? P(¬b|¬a) = 0.9

Page 34: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability and Bayes’ Rule

In Leuven 80% of all cars are red. You see a car at night that does not appear red to you. You know that you correctly identify a red car in only 70% of the cases, while you can identify a non-red car correctly in 90% of the cases.

P(B|A) B: A car is perceived to be red

A: A car is red

T F

T P(b|a) = 0.7

P(¬b|a)=0.3

F P(b|¬a) = 0.1

P(¬b|¬a) = 0.9

Page 35: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability and Bayes’ Rule

In Leuven 80% of all cars are red. You see a car at night that does not appear red to you. You know that you correctly identify a red car in only 70% of the cases, while you can identify a non-red car correctly in 90% of the cases.

2. Compute the probability that the car is actually red, when you perceive a car as red in Leuven at night.

Page 36: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability and Bayes’ Rule

2. Compute the probability that the car is actually red, when you perceive a car as red in Leuven at night.

P(B|A) B: A car is perceived to be red

A: A car is red

T F

T P(b|a) = 0.7

P(¬b|a)=0.3

F P(b|¬a) = 0.1

P(¬b|¬a) = 0.9

A: A car is red

T F

P(a) = 0.8 P(¬a) = 0.2

Page 37: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability and Bayes’ Rule

2. Compute the probability that the car is actually red, when you perceive a car as red in Leuven at night.

Compute P(a|b)

P(B|A) B: A car is perceived to be red

A: A car is red

T F

T P(b|a) = 0.7

P(¬b|a)=0.3

F P(b|¬a) = 0.1

P(¬b|¬a) = 0.9

A: A car is red

T F

P(a) = 0.8 P(¬a) = 0.2

Page 38: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability and Bayes’ Rule

2. Compute the probability that the car is actually red, when you perceive a car as red in Leuven at night.

P(a|b) = P(b|a) · P(a) / P(b)

P(B|A) B: A car is perceived to be red

A: A car is red

T F

T P(b|a) = 0.7

P(¬b|a)=0.3

F P(b|¬a) = 0.1

P(¬b|¬a) = 0.9

A: A car is red

T F

P(a) = 0.8 P(¬a) = 0.2

Page 39: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Probability and Bayes’ Rule

2. Compute the probability that the car is actually red, when you perceive a car as red in Leuven at night.

P(a|b) = P(b|a) · P(a) / P(b)

=

= 0.7·0.8 / (0.7·0.8 + 0.1·0.2) = 0.9655

P(b|a)·P(a)

P(b|a)·P(a) + P(b|¬a)·P(¬a)P(B|A) B: A car is perceived

to be red

A: A car is red

T F

T P(b|a) = 0.7

P(¬b|a)=0.3

F P(b|¬a) = 0.1

P(¬b|¬a) = 0.9

A: A car is red

T F

P(a) = 0.8 P(¬a) = 0.2

Page 40: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Fred’s LISP Dilemma

Page 41: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Fred Lisp Dilemma

The LISP interpreter is unresponsive.

There are only two situations that could cause the LISP interpreter I to stop running: There are either problems with the computer hardware H, or there is a bug in Fred’s code C. Fred is also running an editor E in which he is writing and editing his LISP code;

Page 42: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Fred Lisp Dilemma: Model

I

C H

E

Page 43: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Fred Lisp DilemmaIf the hardware is functioning properly, then the text editor should still be running with a probability of 95%.

When the hardware isn’t functioning properly, the text editor could still be running with a probability of 10%.

The hardware is pretty reliable, and is OK about 99% of the time, whereas Fred’s LISP code is often buggy, say 40% of the time.

In the case of bad hardware and buggy code, the interpreter stops running with a probability of 99%.

In the case of good hardware and buggy code, the interpreter stops running with a probability of 40 %.

In the case of good code and bad hardware, the interpreter stops running with a probability of 95%.

In the case of good code and good hardware, the interpreter stops running with a probability of 10%.

Page 44: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Fred’s Lisp Dilemma: Joint Probability Distributionb) Generally:

Here:

c) Full Joint (no independence information):

24-1 = 15 values needed

d) Utilising network structures (independences between nodes used):

20 +20 + 22 + 21 = 8 values needed

I

C H

E

Page 45: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Fred Lisp Dilemma: Model

I

C H

EC

p(C) bug no_bug

0.4 0.6

H

p(H) good bad

0.99 0.01

C H P(I = responding|C,H)

bug good 0.6

bug bad 0.01

no_bug good 0.9

no_bug bad 0.05

H

p(E|H) good bad

Erunning 0.95 0.1

not_running 0.05 0.9

Page 46: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Calculate probabilityProbability of bug when interpreter stops working:

I

C H

E

Page 47: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Calculate probability(Push summation over E inside: sum = 1)

I

C H

E

Page 48: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian Network

Page 49: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian NetworkIn your local nuclear power station, there is an alarm that senses when a temperature gauge exceeds a given threshold. The gauge measures the temperature of the core. Consider the Boolean variables A (alarm sounds), FA (alarm is faulty), and FG (gauge is faulty) and the multivalued nodes G (gauge reading) and T (actual core temperature).

Page 50: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian NetworkIn your local nuclear power station, there is an alarm that senses when a temperature gauge exceeds a given threshold. The gauge measures the temperature of the core. Consider the Boolean variables A (alarm sounds), FA (alarm is faulty), and FG (gauge is faulty) and the multivalued nodes G (gauge reading) and T (actual core temperature).

1. Draw a Bayesian network for this domain, given that the gauge is more likely to fail when the core temperature gets too high.

Page 51: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian NetworkIn your local nuclear power station, there is an alarm that senses when a temperature gauge exceeds a given threshold. The gauge measures the temperature of the core. The gauge is more likely to fail when the core temperature gets too high.

T

G

Page 52: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian NetworkIn your local nuclear power station, there is an alarm that senses when a temperature gauge exceeds a given threshold. The gauge measures the temperature of the core. The gauge is more likely to fail when the core temperature gets too high.

FGT

G

Page 53: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian NetworkIn your local nuclear power station, there is an alarm that senses when a temperature gauge exceeds a given threshold. The gauge measures the temperature of the core. The gauge is more likely to fail when the core temperature gets too high.

FGT

G FA

A

Page 54: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian NetworkIn your local nuclear power station, there is an alarm that senses when a temperature gauge exceeds a given threshold. The gauge measures the temperature of the core. Consider the Boolean variables A (alarm sounds), FA (alarm is faulty), and FG (gauge is faulty) and the multivalued nodes G (gauge reading) and T (actual core temperature).

2. Suppose there are just two possible actual and measured temperatures, normal and high; the probability that the gauge gives the correct temperature is x when it is working, but y when it is faulty. Give the conditional probability table associated with G.

Page 55: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian NetworkSuppose there are just two possible actual and measured temperatures, normal and high; the probability that the gauge gives the correct temperature is x when it is working, but y when it is faulty. Give the conditional probability table associated with G.

FG = False (correct) FG = True (incorrect)

G T = normal T = high T = normal T = high

G = high

G = normal

Page 56: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian NetworkSuppose there are just two possible actual and measured temperatures, normal and high; the probability that the gauge gives the correct temperature is x when it is working, but y when it is faulty. Give the conditional probability table associated with G.

FG = False (correct) FG = True (incorrect)

G T = normal T = high T = normal T = high

G = high x

G = normal x

Page 57: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian NetworkSuppose there are just two possible actual and measured temperatures, normal and high; the probability that the gauge gives the correct temperature is x when it is working, but y when it is faulty. Give the conditional probability table associated with G.

FG = False (correct) FG = True (incorrect)

G T = normal T = high T = normal T = high

G = high 1 - x x

G = normal x 1 - x

Indirect knowledge!

Page 58: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian NetworkSuppose there are just two possible actual and measured temperatures, normal and high; the probability that the gauge gives the correct temperature is x when it is working, but y when it is faulty. Give the conditional probability table associated with G.

FG = False (correct) FG = True (incorrect)

G T = normal T = high T = normal T = high

G = high 1 - x x 1 - y y

G = normal x 1 - x y 1 - y

Page 59: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian NetworkIn your local nuclear power station, there is an alarm that senses when a temperature gauge exceeds a given threshold. The gauge measures the temperature of the core. Consider the Boolean variables A (alarm sounds), FA (alarm is faulty), and FG (gauge is faulty) and the multivalued nodes G (gauge reading) and T (actual core temperature).

3. Suppose the alarm works correctly unless it is faulty, in which case it never sounds. Give the conditional probability table associated with A.

Page 60: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian NetworkSuppose the alarm works correctly unless it is faulty, in which case it never sounds. Give the conditional probability table associated with A.

FA = False (works) FA = True (faulty)

A G = normal G = high G = normal G = high

A = True (sounds)

A = False (silent)

Page 61: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian NetworkSuppose the alarm works correctly unless it is faulty, in which case it never sounds. Give the conditional probability table associated with A.

FA = False (works) FA = True (faulty)

A G = normal G = high G = normal G = high

A = True (sounds)

0 1

A = False (silent)

1 0

Page 62: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian NetworkSuppose the alarm works correctly unless it is faulty, in which case it never sounds. Give the conditional probability table associated with A.

FA = False (works) FA = True (faulty)

A G = normal G = high G = normal G = high

A = True (sounds)

0 1 0 0

A = False (silent)

1 0 1 1

Page 63: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian NetworkIn your local nuclear power station, there is an alarm that senses when a temperature gauge exceeds a given threshold. The gauge measures the temperature of the core. Consider the Boolean variables A (alarm sounds), FA (alarm is faulty), and FG (gauge is faulty) and the multivalued nodes G (gauge reading) and T (actual core temperature).

4. Suppose the alarm and gauge are working and the alarm sounds. Calculate an expression for the probability that the temperature of the core is too high, in terms of the various conditional probabilities in the network.

Page 64: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian NetworkSuppose the alarm and gauge are working and the alarm sounds. Calculate an expression for the probability that the temperature of the core is too high, in terms of the various conditional probabilities in the network.

FA = False (works), FG = False (works), A = True (sounds)

Page 65: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian NetworkSuppose the alarm and gauge are working and the alarm sounds. Calculate an expression for the probability that the temperature of the core is too high, in terms of the various conditional probabilities in the network.

FA = False (works), FG = False (works), A = True (sounds)

Compute: T = t

Page 66: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian Network

Since the alarm sounds and is not faulty, the gauge reading must be high!

So we can rewrite the problem as follows:

Page 67: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian Network

Applying Bayes’ rule:

Page 68: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian Network

Factorizing the numerator:

Page 69: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian Network

Writing denominator as marginal:

Page 70: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian Network

Factorizing to denominator:

Page 71: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian Network

Factors independent of t before the sum:

Page 72: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian Network

Simplifying:

Page 73: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian Network

Writing out the denominator:

Page 74: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian Network

From the table we know the probabilities:

Page 75: Session 7 Bayesian Networks I - DTAI...0.7 P(¬b|a)= 0.3 F ? P(¬b|¬a) = 0.9 Probability and Bayes’ Rule In Leuven 80% of all cars are red. You see a car at night that does not

Modelling a Bayesian Network

Finally, substituting the probabilities: