PRIOR-SAMPLE

November 7, 2017 · View on GitHub

AIMA3e

function PRIOR-SAMPLE(bn) returns an event sampled from the prior specified by bn
inputs: bn, a Bayesian network specifying joint distribution P(X1, …, Xn)

x ← an event with n elements
foreach variable Xi in X1, …, Xn do
   x[i] ← a random sample from P(Xi | parents(Xi))
return x


Figure ?? A sampling algorithm that generates events from a Bayesian network. Each variable is sampled according to the conditional distribution given the values already sampled for the variable's parents.