Exemple #1
0
def test_reachable_observed_vars_indirect_evidential(simple_model):
    observed_vars = {'13': np.array([1,0])}
    infer = BeliefPropagation(simple_model)
    infer.query(evidence=observed_vars)

    expected = {'13'}
    observed = simple_model.reachable_observed_variables(
        source='9',
        observed=set(observed_vars.keys())
    )
    assert expected == observed
Exemple #2
0
def test_reachable_observed_vars_common_cause(simple_model):
    observed_vars = {'10': np.array([0,1])}
    infer = BeliefPropagation(simple_model)
    infer.query(evidence=observed_vars)

    expected = {'10'}
    observed = simple_model.reachable_observed_variables(
        source='9',
        observed=set(observed_vars.keys())
    )
    assert expected == observed
Exemple #3
0
def test_reachable_observed_vars_blocked_causal(simple_model):
    observed_vars = {'1': np.array([0,1]), '2': np.array([1,0]), '3': np.array([0,1])}
    infer = BeliefPropagation(simple_model)
    infer.query(evidence=observed_vars)

    expected = {'3'}
    observed = simple_model.reachable_observed_variables(
        source='9',
        observed=set(observed_vars.keys())
    )
    assert expected == observed
Exemple #4
0
def test_reachable_observed_vars_direct_common_effect(simple_model):
    observed_vars = {'14': np.array([1,0]), 'x': np.array([1,0])}
    infer = BeliefPropagation(simple_model)
    infer.query(evidence=observed_vars)

    expected = {'x', '14'}
    observed = simple_model.reachable_observed_variables(
        source='9',
        observed=set(observed_vars.keys())
    )
    assert expected == observed