Skip to content

Latest commit

 

History

History
18 lines (15 loc) · 903 Bytes

Rejection-Sampling.md

File metadata and controls

18 lines (15 loc) · 903 Bytes

REJECTION-SAMPLING

AIMA3e

function REJECTION-SAMPLING(X, e, bn, N) returns an estimate of P(X | e)
inputs: X, the query variable
     e, observed values for variables E
     bn, a Bayesian network
     N, the total number of samples to be generated
local variables: N, a vector of counts for each value of X, initially zero

for j = 1 to N do
   x ← PRIOR-SAMPLE(bn)
   if x is consistent with e then
     N[x] ← N[x] + 1 where x is the value of X in x
return NORMALIZE(N)


Figure ?? The rejection-sampling algorithm for answering queries given evidence in a Bayesian network.