def markov_blanket_sample(X, e, bn):
Xnode = bn.variable_node(X)<EOL>Q = ProbDist(X)<EOL>for xi in bn.variable_values(X):<EOL><INDENT>ei = extend(e, X, xi)<EOL>Q[xi] = Xnode.p(xi, e) * product(Yj.p(ei[Yj.variable], ei)<EOL>for Yj in Xnode.children)<EOL><DEDENT>return probability(Q.normalize()[True])<EOL>
Return a sample from P(X | mb) where mb denotes that the
    variables in the Markov blanket of X take their values from event
    e (which must assign a value to each). The Markov blanket of X is
    X's parents, children, and children's parents.