Bayes' Nets
Representation
Probabilistic Models
models describe how the world works
models are always simplifications
may not account for every variable or for all interactions between variables
need to reason about unknown variables, given evidence
examples: explanation, prediction, value of information
Independence
Two variables are independent if:
∀x, y : P(x, y) = P(x)P(y)
∀x, y : P(x | y) = P(x)
X ⊥ Y
Empirical joint distributions: at best “close” to independent
Ex. N fair, independent coin flips
Conditional Independence
P(Toothache, Cavity, Catch)
if I have a cavity, the prob that the probe catches in it doesn’t depend on whether I have a toothache
P(+catch | +toothache, +cavity) = P(+catch | +cavity)
P(+catch | +toothache, -cavity) = P(+catch | -cavity)
Catch is conditionally independent of toothache given cavity:
Our most basic knowledge about uncertain environments
X is conditionally independent of Y given Z iff:
∀x, y, z : P(x, y | z) = P(x | z) P(y | z)
Bayes’ Nets
Two problems with using full joint distribution tables as our probabilistic models
A technique for describing complex joint distributions using simple, local distributions
more properly called graphical models
Graphical Model Notation
nodes: variable (with domains)
can be assigned or unassigned
arcs: interactions
similar to CSP constraints
indicate direct influence between variables

BN Semantics:
a set of nodes, one per variable X
a directed, acyclic graph
a conditional distribution for each node
a collection of distributions over X, one for each combination of parents’ values
conditional probability table (CPT)
Bayes Net = Topology (graph) + Local Conditional Probabilities
Probabilities in a BN
implicitly encode joint distribution
as a product of local conditional distributions
multiply all relevant conditional together to get probability to a full assignment
Ex. Coin Flips
P(h, h, t, h) = (0.5)4
Independence
Size of BN:
How big is a joint distribution over N Boolean variables?
2N
How big is an N-node net if nodes have up to k parents?
O(N * 2k+1)
Assumptions:
P(xi | x1 - - - xi-1) = P(xi | parents(Xi))
conditional independence:
W ⊥ X | Y
Casual Chains
P(x, y, z) = P(x) P(y | x) P(z | y)
Common Cause
P(x, y, z) = P(y) P(x | y) P(z | y)
Common Effect
two causes of one effect (v-structures)
ex. rain and ball game both would cause traffic
General Question: in a given BN, are two variables independent?
Solution: analyze the graph
Reachability
shade evidence nodes, look for paths in the resulting graph
if two nodes are connected by an undirected path not blocked by a shade node, they are conditionally independent
Active/Inactive Paths
a path is active if each triple is active
D-Separation
Query: Xi ⊥ Xj | {Xk1, …, Xkn}
check all undirected paths between Xi and Xj
if one or more is active, then independence is not guaranteed
otherwise (all inactive) independence is guaranteed



Topology Limits Distributions
given some graph topology G, only certain joint distributions can be encoded
the graph structure guarantees certain independences
adding arcs increases the set of distributions, but has several costs
full conditioning can encode any distribution
Inference
Probabilistic Inference
Inference: calculating some useful quantity from a joint probability distribution
ex. posterior probability or most likely explanation

Factor Zoo
joint distribution: P(X, Y)
entries P(x, y) for all x, y
sums to 1
Selected joint: P(x, Y)
a slice of the distribution
entries P(x, y) for fixed x, all y
sums to P(x)
Number of capitals = dimensionality of the table
Single conditional: P(Y | x)
entries P(y | x) for fixed x
sums to 1
Family of conditionals P(Y | X)
multiple conditionals
entries P(y | x) for all x, y
sums to |X|
specified family P(y | X)
entries P(y | x) for fixed y but for all x
sums to … who knows!
In general…
P(Y1 … YN | X1 … XM)
is a “factor”, a multi dimensional array
has values of P(y1 … yN | x1 … xM)
any assigned (lower case) X or Y is a dimension missing (selected) from the array
Inference by Enumeration: Procedural Outline:
track objects called factors
initial factors are local CPTs (one per node)
any known values are selected
join all factors
just like a database join
get all factors over the joining variable
build a new factor over the union of the variables involved
ex. Join on R

eliminate all hidden variables
marginalization
marginalizing early: variable elimination
ex.

take a factor and sum out a variable
shrinks a factor to a smaller one
a projection operation
ex.

normalize
Evidence
if evidence, start with factors that select evidence
no evidence uses initial factors

computing P(L | + r) the initial factor becomes

result will be a selected joint of query and evidence

General variable elimination
Start with initial factors
while there are still hidden variables (not Q or evidence):
pick a hidden variable H
join all factors mentioning H
eliminate H
join all remaining factors and normalize

Continued…

Polytrees:
a directed graph with no undirected cycles
can always find an ordering that is efficient
cut-set conditioning for Bayes’ net inference
Sampling
Approximate Inference: Sampling
very similar to repeated simulation
basic idea
draw N samples from a sampling distribution S
compute an approximate posterior prob
show this converges to the true probability P
Getting a sample is faster than computing the right answer
Sampling from a given distribution:
Step 1: get sample u from uniform distribution over [0, 1)
Step 2: convert this sample u into an outcome for the given distribution by having each target outcome associated with a sub-interval of [0, 1) with sub-interval size equal to prob of the outcome
Ex.

Prior Sampling:

for i = 1, 2, …, n
sample xi from P(Xi | Parents(Xi))
return (x1, x2, …, xn)
this process generates samples with probability:
Sps(x1…xn) = ∏ P(xi | Parents(Xi)) = P(x1…xn)
let the number of samples of an event be: Nps(x1…xn)
lim(N→inf) P(x1…xn) = lim(N→inf) Nps(x1…xn) / N = Sps(x1…xn) = P(x1…xn)
the sampling procedure is consistent if the ratio of the samples in the limit goes towards the actual distribution
Example:

Rejection Sampling

Likelihood Weighting:
problem with rejection sampling
if evidence is unlikely, rejects lots of samples
evidence not exploited as you sample
solution:
fix evidence variables and sample the rest
weight by probability of evidence given parents
Ex.

Algorithm:
input: evidence instantiation
w = 1, 0
for i = 1, 2, .., n
if Xi if an evidence variable
Xi = observation xi for Xi
Set w = w * P[xi | Parents(Xi)]
else
Sample xi from P[Xi | Parents(Xi)]
return (x1, x2, …, xn), w
Likelihood Weighting:
Sampling Distribution if z samples and e fixed evidence:
Sws(z, e) = ∏ P(zi | Parents(Zi))
now samples have weights:
w(z, e) = ∏ P(ei | Parents(Ei))
Together:
Sws(z, e) ⋅ w(z, e) = ∏ P(zi | Parents(Zi)) ∏ P(ei | Parents(Ei)) = P(z, e)
Gibbs Sampling
Procedure:
keep track of full instantiation x1, x2, …, xn
start with an arbitrary instantiation constant with the evidence
sample one variable at a time, conditioned on all the rest, but keep evidence fixed
repeat
Property:
in the limit of repeating this infinitely many times the resulting samples come from the correct distribution
Rationale:
both upstream and downstream variables condition on evidence
Ex.

Efficient Resampling of One Variable:

