Examples of ParticleSet


Examples of aima.core.probability.hmm.ParticleSet

  public static void particleFilterinfDemo() {
    System.out.println("\nParticle Filtering Demo\n");
    HiddenMarkovModel rainman = HMMFactory.createRainmanHMM();
    Randomizer r = new JavaRandomizer();
    ParticleSet starting = rainman.prior().toParticleSet(rainman, r, 1000);
    System.out.println("at the beginning, "
        + starting.numberOfParticlesWithState(HmmConstants.RAINING)
        + " particles 0f 1000 indicate status == 'raining' ");
    System.out.println("at the beginning, "
        + starting.numberOfParticlesWithState(HmmConstants.NOT_RAINING)
        + " particles of 1000 indicate status == 'NOT raining' ");

    System.out
        .println("\n Filtering Particle Set.On perception == 'SEE_UMBRELLA' ..\n");
    ParticleSet afterSeeingUmbrella = starting.filter(
        HmmConstants.SEE_UMBRELLA, r);
    System.out.println("after filtering "
        + afterSeeingUmbrella
            .numberOfParticlesWithState(HmmConstants.RAINING)
        + " particles of 1000 indicate status == 'raining' ");
    System.out.println("after filtering "
        + afterSeeingUmbrella
            .numberOfParticlesWithState(HmmConstants.NOT_RAINING)
        + " particles of 1000 indicate status == 'NOT raining' ");

  }
View Full Code Here

Examples of aima.core.probability.hmm.ParticleSet

  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.probability.hmm.ParticleSet

  @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,
        starting.numberOfParticlesWithState(HmmConstants.NOT_RAINING));

    ParticleSet afterSeeingUmbrella = starting.filter(
        HmmConstants.SEE_UMBRELLA, r);
    Assert.assertEquals(84, afterSeeingUmbrella
        .numberOfParticlesWithState(HmmConstants.RAINING));
    Assert.assertEquals(16, afterSeeingUmbrella
        .numberOfParticlesWithState(HmmConstants.NOT_RAINING));

    // or alternatively
    ParticleSet afterNotSeeingUmbrella = starting.filter(
        HmmConstants.SEE_NO_UMBRELLA, r);
    Assert.assertEquals(12, afterNotSeeingUmbrella
        .numberOfParticlesWithState(HmmConstants.RAINING));
    Assert.assertEquals(88, afterNotSeeingUmbrella
        .numberOfParticlesWithState(HmmConstants.NOT_RAINING));
  }
View Full Code Here

Examples of aima.core.probability.hmm.ParticleSet

  @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,
        starting.numberOfParticlesWithState(HmmConstants.DOOR_CLOSED));

    // step one = robot takes no action but senses open door
    ParticleSet afterStepOne = starting.filter(HmmConstants.SEE_DOOR_OPEN,
        r);
    Assert.assertEquals(66,
        afterStepOne.numberOfParticlesWithState(HmmConstants.DOOR_OPEN));
    Assert.assertEquals(34, afterStepOne
        .numberOfParticlesWithState(HmmConstants.DOOR_CLOSED));

    // step two = robot pushes the door and then senses open door
    ParticleSet afterStepTwo = starting.filter(HmmConstants.PUSH_DOOR,
        HmmConstants.SEE_DOOR_OPEN, r);
    Assert.assertEquals(100,
        afterStepTwo.numberOfParticlesWithState(HmmConstants.DOOR_OPEN));
    Assert.assertEquals(0, afterStepTwo
        .numberOfParticlesWithState(HmmConstants.DOOR_CLOSED));
  }
View Full Code Here

Examples of aima.core.probability.hmm.ParticleSet

  }

  @Test
  public void testRandomVariableConversionToParticleSet() {
    VarDistribution rv = rainman.prior();
    ParticleSet ps = rv.toParticleSet(rainman, randomizer, 10);
    Assert.assertEquals(5,
        ps.numberOfParticlesWithState(HmmConstants.RAINING));
    Assert.assertEquals(5,
        ps.numberOfParticlesWithState(HmmConstants.NOT_RAINING));
  }
View Full Code Here

Examples of aima.core.probability.hmm.ParticleSet

  @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,
        ps2.numberOfParticlesWithState(HmmConstants.NOT_RAINING));
  }
View Full Code Here

Examples of aima.core.probability.hmm.ParticleSet

  @Test
  public void testParticleSetForPredictedStateGeneratedFromOldStateParticleSet() {
    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 ps = rainman.prior().toParticleSet(rainman, r, 10);
    Assert.assertEquals(6,
        ps.numberOfParticlesWithState(HmmConstants.RAINING));
    Assert.assertEquals(4,
        ps.numberOfParticlesWithState(HmmConstants.NOT_RAINING));

    ParticleSet nps = ps.generateParticleSetForPredictedState(r);
    Assert.assertEquals(7,
        nps.numberOfParticlesWithState(HmmConstants.RAINING));
    Assert.assertEquals(3,
        nps.numberOfParticlesWithState(HmmConstants.NOT_RAINING));
  }
View Full Code Here

Examples of aima.core.probability.hmm.ParticleSet

  @Test
  public void testParticleSetForPerceptionUpdatedStateGeneratedFromPredictedStateParticleSetGivenPerception() {
    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, 10);
    ParticleSet predicted = starting
        .generateParticleSetForPredictedState(r);

    ParticleSet updatedWithPerceptionOfUmbrella = predicted
        .perceptionUpdate(HmmConstants.SEE_UMBRELLA, r);
    Assert.assertEquals(9, updatedWithPerceptionOfUmbrella
        .numberOfParticlesWithState(HmmConstants.RAINING));
    Assert.assertEquals(1, updatedWithPerceptionOfUmbrella
        .numberOfParticlesWithState(HmmConstants.NOT_RAINING));

    ParticleSet updatedWithPerceptionOfNoUmbrella = predicted
        .perceptionUpdate(HmmConstants.SEE_NO_UMBRELLA, r);
    Assert.assertEquals(2, updatedWithPerceptionOfNoUmbrella
        .numberOfParticlesWithState(HmmConstants.RAINING));
    Assert.assertEquals(8, updatedWithPerceptionOfNoUmbrella
        .numberOfParticlesWithState(HmmConstants.NOT_RAINING));
  }
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.