AIMA.Test.Core.Unit.Probability.Reasoning.ParticleFilterTest.testParticleSetForPerceptionUpdatedStateGeneratedFromPredictedStateParticleSetGivenPerception C# (CSharp) Method

testParticleSetForPerceptionUpdatedStateGeneratedFromPredictedStateParticleSetGivenPerception() private method

        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.AreEqual(9, updatedWithPerceptionOfUmbrella
                    .numberOfParticlesWithState(HmmConstants.RAINING));
            Assert.AreEqual(1, updatedWithPerceptionOfUmbrella
                    .numberOfParticlesWithState(HmmConstants.NOT_RAINING));

            ParticleSet updatedWithPerceptionOfNoUmbrella = predicted
                    .perceptionUpdate(HmmConstants.SEE_NO_UMBRELLA, r);
            Assert.AreEqual(2, updatedWithPerceptionOfNoUmbrella
                    .numberOfParticlesWithState(HmmConstants.RAINING));
            Assert.AreEqual(8, updatedWithPerceptionOfNoUmbrella
                    .numberOfParticlesWithState(HmmConstants.NOT_RAINING));
        }
    }