smooth() public method

public smooth ( String perception ) : RandomVariable
perception String
return RandomVariable
Beispiel #1
0
        public void testTwoStepFixedLagSmoothingOnRainManHmm()
        {
            FixedLagSmoothing fls = new FixedLagSmoothing(rainmanHmm, 2);

            RandomVariable smoothedOne = fls.smooth(HmmConstants.SEE_UMBRELLA); // see
            // umbrella on day one
            Assert.IsNull(smoothedOne);

            smoothedOne = fls.smooth(HmmConstants.SEE_UMBRELLA); // see
            // umbrella on day two
            Assert.AreEqual(0.653, smoothedOne
                    .getProbabilityOf(HmmConstants.RAINING), TOLERANCE);
            Assert.AreEqual(0.346, smoothedOne
                    .getProbabilityOf(HmmConstants.NOT_RAINING), TOLERANCE);

            RandomVariable smoothedTwo = fls.smooth(HmmConstants.SEE_UMBRELLA);// see
            // umbrella on day 3
            Assert.AreEqual(0.894, smoothedTwo
                    .getProbabilityOf(HmmConstants.RAINING), TOLERANCE);
            Assert.AreEqual(0.105, smoothedTwo
                    .getProbabilityOf(HmmConstants.NOT_RAINING), TOLERANCE);
        }
Beispiel #2
0
        public void testOneStepFixedLagSmoothingOnRainManHmm()
        {
            FixedLagSmoothing fls = new FixedLagSmoothing(rainmanHmm, 1);

            RandomVariable smoothedDayZero = fls.smooth(HmmConstants.SEE_UMBRELLA); // see
            // umbrella on day one
            Assert.AreEqual(0.627, smoothedDayZero
                    .getProbabilityOf(HmmConstants.RAINING), TOLERANCE);

            RandomVariable smoothedDayOne = fls.smooth(HmmConstants.SEE_UMBRELLA); // see
            // umbrella on day two
            Assert.AreEqual(0.883, smoothedDayOne
                    .getProbabilityOf(HmmConstants.RAINING), TOLERANCE);
            Assert.AreEqual(0.117, smoothedDayOne
                    .getProbabilityOf(HmmConstants.NOT_RAINING), TOLERANCE);

            RandomVariable smoothedDayTwo = fls
                    .smooth(HmmConstants.SEE_NO_UMBRELLA); // see no umbrella on
            // day three
            Assert.AreEqual(0.799, smoothedDayTwo
                    .getProbabilityOf(HmmConstants.RAINING), TOLERANCE);
            Assert.AreEqual(0.201, smoothedDayTwo
                    .getProbabilityOf(HmmConstants.NOT_RAINING), TOLERANCE);
        }
Beispiel #3
0
        public void testOneStepFixedLagSmoothingOnRainManHmmWithDifferingEvidence()
        {
            FixedLagSmoothing fls = new FixedLagSmoothing(rainmanHmm, 1);

            RandomVariable smoothedDayZero = fls.smooth(HmmConstants.SEE_UMBRELLA);// see
            // umbrella on day one
            Assert.AreEqual(0.627, smoothedDayZero
                    .getProbabilityOf(HmmConstants.RAINING), TOLERANCE);

            RandomVariable smoothedDayOne = fls
                    .smooth(HmmConstants.SEE_NO_UMBRELLA);// no umbrella on day
            // two
            Assert.AreEqual(0.702, smoothedDayOne
                    .getProbabilityOf(HmmConstants.RAINING), TOLERANCE);
            Assert.AreEqual(0.297, smoothedDayOne
                    .getProbabilityOf(HmmConstants.NOT_RAINING), TOLERANCE);
        }
Beispiel #4
0
        public void testForwardBackwardAndFixedLagSmoothingGiveSameResults()
        {
            List<String> perceptions = new List<String>();

            String dayOnePerception = HmmConstants.SEE_UMBRELLA;
            String dayTwoPerception = HmmConstants.SEE_UMBRELLA;
            String dayThreePerception = HmmConstants.SEE_NO_UMBRELLA;

            perceptions.Add(dayOnePerception);
            perceptions.Add(dayTwoPerception);
            perceptions.Add(dayThreePerception);

            List<RandomVariable> fbResults = rainmanHmm
                    .forward_backward(perceptions);
            Assert.AreEqual(4, fbResults.Count);

            // RandomVariable fbDayOneResult = fbResults.get(1);
            // System.Console.WriteLine(fbDayOneResult);

            FixedLagSmoothing fls = new FixedLagSmoothing(rainmanHmm, 2);

            Assert.IsNull(fls.smooth(dayOnePerception));
            // System.Console.WriteLine(fls.smooth(dayTwoPerception));
            // RandomVariable flsDayoneResult = fls.smooth(dayThreePerception);
            // System.Console.WriteLine(flsDayoneResult);
        }