Examples of AssignmentProposition


Examples of aima.core.probability.proposition.AssignmentProposition

  }

  protected void test_ToothacheCavityCatchModel(ProbabilityModel model) {
    Assert.assertTrue(model.isValid());

    AssignmentProposition atoothache = new AssignmentProposition(
        ExampleRV.TOOTHACHE_RV, Boolean.TRUE);
    AssignmentProposition anottoothache = new AssignmentProposition(
        ExampleRV.TOOTHACHE_RV, Boolean.FALSE);
    AssignmentProposition acavity = new AssignmentProposition(
        ExampleRV.CAVITY_RV, Boolean.TRUE);
    AssignmentProposition anotcavity = new AssignmentProposition(
        ExampleRV.CAVITY_RV, Boolean.FALSE);
    AssignmentProposition acatch = new AssignmentProposition(
        ExampleRV.CATCH_RV, Boolean.TRUE);
    AssignmentProposition anotcatch = new AssignmentProposition(
        ExampleRV.CATCH_RV, Boolean.FALSE);

    // AIMA3e pg. 485
    Assert.assertEquals(0.2, model.prior(acavity), DELTA_THRESHOLD);
    Assert.assertEquals(0.6, model.posterior(acavity, atoothache),
View Full Code Here

Examples of aima.core.probability.proposition.AssignmentProposition

    // Should be able to run all the same queries for this independent
    // sub model.
    test_ToothacheCavityCatchModel(model);

    // AIMA3e pg. 486
    AssignmentProposition asunny = new AssignmentProposition(
        ExampleRV.WEATHER_RV, "sunny");
    AssignmentProposition arain = new AssignmentProposition(
        ExampleRV.WEATHER_RV, "rain");
    AssignmentProposition acloudy = new AssignmentProposition(
        ExampleRV.WEATHER_RV, "cloudy");
    AssignmentProposition asnow = new AssignmentProposition(
        ExampleRV.WEATHER_RV, "snow");

    Assert.assertEquals(0.6, model.prior(asunny), DELTA_THRESHOLD);
    Assert.assertEquals(0.1, model.prior(arain), DELTA_THRESHOLD);
    Assert.assertEquals(0.29, model.prior(acloudy), DELTA_THRESHOLD);
    Assert.assertEquals(0.01, model.prior(asnow), DELTA_THRESHOLD);

    // AIMA3e pg. 488
    // P(sunny, cavity)
    // P(sunny AND cavity)
    AssignmentProposition atoothache = new AssignmentProposition(
        ExampleRV.TOOTHACHE_RV, Boolean.TRUE);
    AssignmentProposition acatch = new AssignmentProposition(
        ExampleRV.CATCH_RV, Boolean.TRUE);
    AssignmentProposition acavity = new AssignmentProposition(
        ExampleRV.CAVITY_RV, Boolean.TRUE);
    ConjunctiveProposition sunnyAndCavity = new ConjunctiveProposition(
        asunny, acavity);

    // 0.6 (sunny) * 0.2 (cavity) = 0.12
View Full Code Here

Examples of aima.core.probability.proposition.AssignmentProposition

  // AIMA3e pg. 496
  protected void test_MeningitisStiffNeckModel(ProbabilityModel model) {

    Assert.assertTrue(model.isValid());

    AssignmentProposition ameningitis = new AssignmentProposition(
        ExampleRV.MENINGITIS_RV, true);
    AssignmentProposition anotmeningitis = new AssignmentProposition(
        ExampleRV.MENINGITIS_RV, false);
    AssignmentProposition astiffNeck = new AssignmentProposition(
        ExampleRV.STIFF_NECK_RV, true);
    AssignmentProposition anotstiffNeck = new AssignmentProposition(
        ExampleRV.STIFF_NECK_RV, false);

    // P(stiffNeck | meningitis) = 0.7
    Assert.assertEquals(0.7, model.posterior(astiffNeck, ameningitis),
        DELTA_THRESHOLD);
View Full Code Here

Examples of aima.core.probability.proposition.AssignmentProposition

  // AIMA3e pg. 512
  protected void test_BurglaryAlarmModel(ProbabilityModel model) {
    Assert.assertTrue(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.assertEquals(0.00062811126, model.prior(ajohnCalls, amaryCalls,
        aalarm, anotburglary, anotearthquake), DELTA_THRESHOLD);
View Full Code Here

Examples of aima.core.probability.proposition.AssignmentProposition

  // PROTECTED
  //
  protected void test_RollingPairFairDiceModel_Distributions(
      FiniteProbabilityModel model) {

    AssignmentProposition ad1_1 = new AssignmentProposition(
        ExampleRV.DICE_1_RV, 1);
    CategoricalDistribution dD1_1 = model.priorDistribution(ad1_1);
    Assert.assertArrayEquals(new double[] { 1.0 / 6.0 }, dD1_1.getValues(),
        DELTA_THRESHOLD);
View Full Code Here

Examples of aima.core.probability.proposition.AssignmentProposition

  }

  protected void test_ToothacheCavityCatchModel_Distributions(
      FiniteProbabilityModel model) {

    AssignmentProposition atoothache = new AssignmentProposition(
        ExampleRV.TOOTHACHE_RV, Boolean.TRUE);
    AssignmentProposition anottoothache = new AssignmentProposition(
        ExampleRV.TOOTHACHE_RV, Boolean.FALSE);
    AssignmentProposition acatch = new AssignmentProposition(
        ExampleRV.CATCH_RV, Boolean.TRUE);
    AssignmentProposition anotcatch = new AssignmentProposition(
        ExampleRV.CATCH_RV, Boolean.FALSE);

    // AIMA3e pg. 493
    // P<>(Cavity | toothache) = <0.6, 0.4>
    Assert.assertArrayEquals(new double[] { 0.6, 0.4 }, model
View Full Code Here

Examples of aima.core.probability.proposition.AssignmentProposition

  }

  protected void test_ToothacheCavityCatchWeatherModel_Distributions(
      FiniteProbabilityModel model) {

    AssignmentProposition asunny = new AssignmentProposition(
        ExampleRV.WEATHER_RV, "sunny");
    AssignmentProposition acavity = new AssignmentProposition(
        ExampleRV.CAVITY_RV, Boolean.TRUE);

    // Should be able to run all the same queries for this independent
    // sub model.
    test_ToothacheCavityCatchModel_Distributions(model);
View Full Code Here

Examples of aima.core.probability.proposition.AssignmentProposition

  // AIMA3e pg. 496
  protected void test_MeningitisStiffNeckModel_Distributions(
      FiniteProbabilityModel model) {

    AssignmentProposition astiffNeck = new AssignmentProposition(
        ExampleRV.STIFF_NECK_RV, true);

    // AIMA3e pg. 497
    // P<>(Mengingitis | stiffneck) = &alpha;<P(s | m)P(m), P(s | ~m)P(~m)>
    CategoricalDistribution dMeningitisGivenStiffNeck = model
View Full Code Here

Examples of aima.core.probability.proposition.AssignmentProposition

  }

  protected void test_BurglaryAlarmModel_Distributions(
      FiniteProbabilityModel model) {

    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 ajohnCalls = new AssignmentProposition(
        ExampleRV.JOHN_CALLS_RV, Boolean.TRUE);
    AssignmentProposition amaryCalls = new AssignmentProposition(
        ExampleRV.MARY_CALLS_RV, Boolean.TRUE);

    // AIMA3e. pg. 514
    // P<>(Alarm | JohnCalls = true, MaryCalls = true, Burglary = false,
    // Earthquake = false)
View Full Code Here

Examples of aima.core.probability.proposition.AssignmentProposition

  @Test
  public void testLikelihoodWeighting_basic() {
    BayesianNetwork bn = BayesNetExampleFactory
        .constructCloudySprinklerRainWetGrassNetwork();
    AssignmentProposition[] e = new AssignmentProposition[] { new AssignmentProposition(
        ExampleRV.SPRINKLER_RV, Boolean.TRUE) };
    MockRandomizer r = new MockRandomizer(
        new double[] { 0.5, 0.5, 0.5, 0.5 });

    LikelihoodWeighting lw = new LikelihoodWeighting(r);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.