Examples of MockRandomizer


Examples of aima.core.util.MockRandomizer

  @Test
  public void testPriorSample_basic() {
    // AIMA3e pg. 530
    BayesianNetwork bn = BayesNetExampleFactory
        .constructCloudySprinklerRainWetGrassNetwork();
    MockRandomizer r = new MockRandomizer(
        new double[] { 0.5, 0.5, 0.5, 0.5 });

    PriorSample ps = new PriorSample(r);
    Map<RandomVariable, Object> event = ps.priorSample(bn);
View Full Code Here

Examples of aima.core.util.MockRandomizer

  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);

    double[] estimate = lw.likelihoodWeighting(
View Full Code Here

Examples of aima.core.util.MockRandomizer

        new AssignmentProposition(ExampleRV.CLOUDY_RV, Boolean.TRUE),
        new AssignmentProposition(ExampleRV.WET_GRASS_RV, Boolean.TRUE) };
    // sample P(Sprinkler | Cloudy = true) = <0.1, 0.9>; suppose
    // Sprinkler=false
    // sample P(Rain | Cloudy = true) = <0.8, 0.2>; suppose Rain=true
    MockRandomizer r = new MockRandomizer(new double[] { 0.5, 0.5 });

    LikelihoodWeighting lw = new LikelihoodWeighting(r);
    double[] estimate = lw.likelihoodWeighting(
        new RandomVariable[] { ExampleRV.RAIN_RV }, e, bn, 1)
        .getValues();
View Full Code Here

Examples of aima.core.util.MockRandomizer

  public void testGibbsAsk_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, 0.5, 0.5, 0.6, 0.5, 0.5, 0.6, 0.5, 0.5 });

    GibbsAsk ga = new GibbsAsk(r);

    double[] estimate = ga.gibbsAsk(
View Full Code Here

Examples of aima.core.util.MockRandomizer

    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();
View Full Code Here

Examples of aima.core.util.MockRandomizer

        }

        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();
View Full Code Here

Examples of aima.core.util.MockRandomizer

  @Before
  public void setUp() {
    rainman = HMMFactory.createRainmanHMM();
    robot = HMMFactory.createRobotHMM();

    randomizer = new MockRandomizer(new double[] { 0.1, 0.9 });
    particleSet = new ParticleSet(rainman);
    particleSet.add(new Particle(HmmConstants.RAINING));
    particleSet.add(new Particle(HmmConstants.RAINING));
    particleSet.add(new Particle(HmmConstants.RAINING));
    particleSet.add(new Particle(HmmConstants.NOT_RAINING));
View Full Code Here

Examples of aima.core.util.MockRandomizer

    particleSet.add(new Particle(HmmConstants.NOT_RAINING));
  }

  @Test
  public void testFilteringWithParticleSetsWorksForRainmanHmm() {
    Randomizer r = new MockRandomizer(new double[] { 0.1, 0.2, 0.3, 0.4,
        0.5, 0.6, 0.7, 0.8, 0.9 });
    ParticleSet starting = rainman.prior().toParticleSet(rainman, r, 100);
    Assert.assertEquals(56,
        starting.numberOfParticlesWithState(HmmConstants.RAINING));
    Assert.assertEquals(44,
View Full Code Here

Examples of aima.core.util.MockRandomizer

        .numberOfParticlesWithState(HmmConstants.NOT_RAINING));
  }

  @Test
  public void testFilteringWithParticleSetsForRobotHmm() {
    Randomizer r = new MockRandomizer(new double[] { 0.1, 0.2, 0.3, 0.4,
        0.5, 0.6, 0.7, 0.8, 0.9 });
    ParticleSet starting = robot.prior().toParticleSet(robot, r, 100);
    Assert.assertEquals(56,
        starting.numberOfParticlesWithState(HmmConstants.DOOR_OPEN));
    Assert.assertEquals(44,
View Full Code Here

Examples of aima.core.util.MockRandomizer

  }

  @Test
  public void testRoundTripConversion() {
    VarDistribution rv = particleSet.toRandomVariable();
    Randomizer r = new MockRandomizer(new double[] { 0.1, 0.2, 0.3, 0.4,
        0.9 });
    ParticleSet ps2 = rv.toParticleSet(rainman, r, 10);
    Assert.assertEquals(8,
        ps2.numberOfParticlesWithState(HmmConstants.RAINING));
    Assert.assertEquals(2,
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.