Package aima.core.probability.bayes.approx

Examples of aima.core.probability.bayes.approx.RejectionSampling


  public static void bayesRejectionSamplingDemo() {
    System.out.println("DEMO: Bayes Rejection Sampling N = " + NUM_SAMPLES);
    System.out.println("==============================");
    demoToothacheCavityCatchModel(new FiniteBayesModel(
        BayesNetExampleFactory.constructToothacheCavityCatchNetwork(),
        new BayesInferenceApproxAdapter(new RejectionSampling(),
            NUM_SAMPLES)));
    demoBurglaryAlarmModel(new FiniteBayesModel(
        BayesNetExampleFactory.constructBurglaryAlarmNetwork(),
        new BayesInferenceApproxAdapter(new RejectionSampling(),
            NUM_SAMPLES)));
    System.out.println("==============================");
  }
View Full Code Here


    BayesianNetwork bn = BayesNetExampleFactory
        .constructCloudySprinklerRainWetGrassNetwork();
    AssignmentProposition[] e = new AssignmentProposition[] { new AssignmentProposition(
        ExampleRV.SPRINKLER_RV, Boolean.TRUE) };
    MockRandomizer r = new MockRandomizer(new double[] { 0.1 });
    RejectionSampling rs = new RejectionSampling(new PriorSample(r));

    double[] estimate = rs.rejectionSampling(
        new RandomVariable[] { ExampleRV.RAIN_RV }, e, bn, 100)
        .getValues();

    Assert.assertArrayEquals(new double[] { 1.0, 0.0 }, estimate,
        DELTA_THRESHOLD);
View Full Code Here

        ma[i + 3] = 0.1; // i.e. WetGrass=true
      }
    }
    MockRandomizer r = new MockRandomizer(ma);
    RejectionSampling rs = new RejectionSampling(new PriorSample(r));

    double[] estimate = rs.rejectionSampling(
        new RandomVariable[] { ExampleRV.RAIN_RV }, e, bn, 100)
        .getValues();

    Assert.assertArrayEquals(new double[] { 0.2962962962962963,
        0.7037037037037037 }, estimate, DELTA_THRESHOLD);
View Full Code Here

TOP

Related Classes of aima.core.probability.bayes.approx.RejectionSampling

Copyright © 2018 www.massapicom. 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.