// AIMA3e pg. 512
protected void test_BurglaryAlarmModel(ProbabilityModel model)
{
Assert.IsTrue(model.isValid());
AssignmentProposition aburglary = new AssignmentProposition(
ExampleRV.BURGLARY_RV, Boolean.TRUE);
AssignmentProposition anotburglary = new AssignmentProposition(
ExampleRV.BURGLARY_RV, Boolean.FALSE);
AssignmentProposition anotearthquake = new AssignmentProposition(
ExampleRV.EARTHQUAKE_RV, Boolean.FALSE);
AssignmentProposition aalarm = new AssignmentProposition(
ExampleRV.ALARM_RV, Boolean.TRUE);
AssignmentProposition anotalarm = new AssignmentProposition(
ExampleRV.ALARM_RV, Boolean.FALSE);
AssignmentProposition ajohnCalls = new AssignmentProposition(
ExampleRV.JOHN_CALLS_RV, Boolean.TRUE);
AssignmentProposition amaryCalls = new AssignmentProposition(
ExampleRV.MARY_CALLS_RV, Boolean.TRUE);
// AIMA3e pg. 514
Assert.AreEqual(0.00062811126, model.prior(ajohnCalls, amaryCalls,
aalarm, anotburglary, anotearthquake), DELTA_THRESHOLD);
Assert.AreEqual(0.00049800249, model.prior(ajohnCalls, amaryCalls,
anotalarm, anotburglary, anotearthquake), DELTA_THRESHOLD);
// AIMA3e pg. 524
// P(Burglary = true | JohnCalls = true, MaryCalls = true) = 0.00059224
Assert.AreEqual(0.00059224,
model.prior(aburglary, ajohnCalls, amaryCalls), DELTA_THRESHOLD);
// P(Burglary = false | JohnCalls = true, MaryCalls = true) = 0.0014919
Assert.AreEqual(0.00149185764899,
model.prior(anotburglary, ajohnCalls, amaryCalls),
DELTA_THRESHOLD);
}