CS 4100: Artificial Intelligence Bayes’ Nets: Sampling
Jan-Willem van de Meent, Northeastern University
[These slides were created by Dan Klein and Pieter Abbeel for CS188 Intro to AI at UC Berkeley. All CS188 materials are available at http://ai.berkeley.edu.]
Bayes’ Net Representation
- A
A di directed, d, acyclic graph ph, o , one n node p per r random v variable
- A
A co conditional al probab ability tab able (CP CPT) ) for each node de
- A collection of distributions over X, one for
each possible assignment to parent variables
- Ba
Bayes’ne nets implicitly enc ncode jo join int dis istrib ributio ions
- As a product of local conditional distributions
- To see what probability a BN gives to a full assignment,
multiply all the relevant conditionals together:
Variable Elimination
- Interleave
ve jo join inin ing and and marginalizi zing
- dk entries
s computed for a factor ove ver k va variables s with domain si size zes s d
- Or
Orde dering of elimination of hidden va variables s can can af affect ect si size ze of factors s ge generate ted
- Worst
st case se: running time exp xponential in in the si size ze of the Baye yes’ s’ net
… …
Approximate Inference: Sampling Sampling
- Sampling is a lot like
ke repeated simulation
- Predicting the weather, basketball games, …
- Ba
Basic idea
- Dr
Draw N samples from a sampling distribution S
- Co
Compute an approximate posterior probability
- Show this co
conver verges ges to the true probability P
- Why
Why sampl ple?
- Re
Reinforcement Learning: Can approximate (q-)values even when you don’t know the transition function
- In
Inference: : getting a sample is faster than computing the right answer (e.g. with variable elimination)
Sampling
- Sampling from give
ven dist stribution
- St
Step p 1: Get sample u from uniform distribution over [0 [0, 1)
- E.g. ra
random() m() in python
- St
Step p 2: Convert this sample u into an outcome for the given distribution by having each target outcome associated with a sub-interval of [0 [0,1) with sub-interval size equal to probability of the outcome
- Example
- If ra
random() returns u = = 0.83, then our sample is C = = blue
- E.g, after sampling 8 times:
C P(C) red 0.6 green 0.1 blue 0.3
0.6 0.7 1.0 u u = 0.83
Sampling in Bayes’ Nets
- Pr
Prior ior Sa Samp mplin ling
- Re
Rejecti tion Sampling
- Like
kelihood Weighting
- Gi