4-AI Probability
4-AI Probability
Introduction to probability
Uncertainty
• So far in course, everything deterministic
• If I walk with my umbrella, I will not get wet
• But: there is some chance my umbrella will break!
• Intelligent systems must take possibility of failure
into account…
– May want to have backup umbrella in city that is often
windy and rainy
• … but should not be excessively conservative
– Two umbrellas not worthwhile for city that is usually not
windy
• Need quantitative notion of uncertainty
Probability
Y 6 1/36 1/36 1/36 1/36 1/36 1/36
• Example: roll two dice
• Random variables: 5 1/36 1/36 1/36 1/36 1/36 1/36
– E.g., (6, 1): X=6, Y=1 1 1/36 1/36 1/36 1/36 1/36 1/36
– Atomic event or sample point tells us the
1 2 3 4 5 6
complete state of the world, i.e., values X
• An event is a proposition about
of all random variables
the state (=subset of states)
• Exactly one atomic event will happen;
each atomic event has a ≥0 – X+Y = 7
probability; sum to 1 • Probability of event = sum of
– E.g., P(X=1 and Y=6) = 1/36 probabilities of atomic events
where event is true
Cards and combinatorics
• Draw a hand of 5 cards from a standard deck with 4*13 =
52 cards (4 suits, 13 ranks each)
• Each of the (52 choose 5) hands has same probability 1/
(52 choose 5)
• Probability of event = number of hands in that event / (52
choose 5)
• What is the probability that…
– no two cards have the same rank?
– you have a flush (all cards the same suit?)
– you have a straight (5 cards in order of rank, e.g., 8, 9, 10, J, Q)?
– you have a straight flush?
– you have a full house (three cards have the same rank and the two
other cards have the same rank)?
Facts about probabilities of events
• If events A and B are disjoint, then
– P(A or B) = P(A) + P(B)
• More generally:
– P(A or B) = P(A) + P(B) - P(A and B)
• If events A1, …, An are disjoint and exhaustive
(one of them must happen) then P(A1) + … +
P(An) = 1
– Special case: for any random variable, ∑x P(X=x) =
1
• Marginalization: P(X=x) = ∑y P(X=x and Y=y)
Conditional probability
• We might know something about the world – e.g., “X+Y=6 or
X+Y=7” – given this (and only this), what is the probability of Y=5?
• Part of the sample space is eliminated; probabilities are
renormalized to sum to 1
Y Y
6 1/36 1/36 1/36 1/36 1/36 1/36 6 1/11 0 0 0 0 0
A and B B
A
Rain in
Durham
.2 .1
(disclaimer:
Sun in
Durham
.2 .5 no idea if
these
numbers are
• What is the probability of realistic)
5 1/72 1/72 1/72 1/72 1/72 1/72 5 1/48 1/72 1/72 1/72 1/72 1/144
4 1/72 1/72 1/72 1/72 1/72 1/72 4 1/48 1/72 1/72 1/72 1/72 1/144
3 1/72 1/72 1/72 1/72 1/72 1/72 3 1/48 1/72 1/72 1/72 1/72 1/144
2 1/72 1/72 1/72 1/72 1/72 1/72 2 1/48 1/72 1/72 1/72 1/72 1/144
1 1/72 1/72 1/72 1/72 1/72 1/72 1 1/32 1/48 1/48 1/48 1/48 1/96
1 2 3 4 5 6 X 1 2 3 4 5 6X
• What is P(Y=6)?
• What is P(Y=6|X=1)?
• Are they independent?
Conditional independence
• Intuition:
– the only reason that X tells us something about Y,
– is that X tells us something about Z,
– and Z tells us something about Y
• If we already know Z, then X tells us nothing
about Y
• P(Y | Z, X) = P(Y | Z) or
• P(X, Y | Z) = P(X | Z)P(Y | Z)
• “X and Y are conditionally independent given Z”
Medical diagnosis
• X: does patient have flu?
• Y: does patient have headache?
• Z: does patient have fever?
(disclaimer:
• P(Y,Z|X) = P(Y|X)P(Z|X) no idea if
these
• P(X=1) = .2 numbers are
realistic)
• P(Y=1 | X=1) = .5, P(Y=1 | X=0) = .2
• P(Z=1 | X=1) = .4, P(Z=1 | X=0) = .1
• What is P(X=1|Y=1,Z=0)?
Not wet
Conditioning can also introduce dependence Not raining
Raining