def enumerate_joint_ask(X, e, P):
    """Return a probability distribution over the values of the variable X,
    given the {var:val} observations e, in the JointProbDist P. [Section 13.3]
    >>> P = JointProbDist(['X', 'Y'])
    >>> P[0,0] = 0.25; P[0,1] = 0.5; P[1,1] = P[2,1] = 0.125
    >>> enumerate_joint_ask('X', dict(Y=1), P).show_approx()
    '0: 0.667, 1: 0.167, 2: 0.167'
    """
    assert X not in e, "Query variable must be distinct from evidence"
    Q = ProbDist(X) # probability distribution for X, initially empty
    Y = [v for v in P.variables if v != X and v not in e] # hidden vars.
    for xi in P.values(X):
        Q[xi] = enumerate_joint(Y, extend(e, X, xi), P)
    return Q.normalize()
def enumerate_joint_ask(X, e, P):
    """Return a probability distribution over the values of the variable X,
    given the {var:val} observations e, in the JointProbDist P. [Section 13.3]
    >>> P = JointProbDist(['X', 'Y'])
    >>> P[0,0] = 0.25; P[0,1] = 0.5; P[1,1] = P[2,1] = 0.125
    >>> enumerate_joint_ask('X', dict(Y=1), P).show_approx()
    '0: 0.667, 1: 0.167, 2: 0.167'
    """
    assert X not in e, "Query variable must be distinct from evidence"
    Q = ProbDist(X) # probability distribution for X, initially empty
    Y = [v for v in P.variables if v != X and v not in e] # hidden vars.
    for xi in P.values(X):
        Q[xi] = enumerate_joint(Y, extend(e, X, xi), P)
    return Q.normalize()
def enumerate_joint_ask ( X , e , P ) : assert X not in e , "Query variable must be distinct from evidence" Q = ProbDist ( X ) # probability distribution for X, initially empty Y = [ v for v in P . variables if v != X and v not in e ] # hidden vars. for xi in P . values ( X ) : Q [ xi ] = enumerate_joint ( Y , extend ( e , X , xi ) , P ) return Q . normalize ( )
Return a probability distribution over the values of the variable X,
    given the {var:val} observations e, in the JointProbDist P. [Section 13.3]
    >>> P = JointProbDist(['X', 'Y'])
    >>> P[0,0] = 0.25; P[0,1] = 0.5; P[1,1] = P[2,1] = 0.125
    >>> enumerate_joint_ask('X', dict(Y=1), P).show_approx()
    '0: 0.667, 1: 0.167, 2: 0.167'
Return a probability distribution over the values of the variable X given the { var : val } observations e in the JointProbDist P . [ Section 13 . 3 ] >>> P = JointProbDist ( [ X Y ] ) >>> P [ 0 0 ] = 0 . 25 ; P [ 0 1 ] = 0 . 5 ; P [ 1 1 ] = P [ 2 1 ] = 0 . 125 >>> enumerate_joint_ask ( X dict ( Y = 1 ) P ) . show_approx () 0 : 0 . 667 1 : 0 . 167 2 : 0 . 167