HmmEvaluator { public static double modelLikelihood(HmmModel model, int[] outputSequence, boolean scaled) { return modelLikelihood(HmmAlgorithms.forwardAlgorithm(model, outputSequence, scaled), scaled); } private  HmmEvaluator(); static int[] predict(HmmModel model, int steps); static int[] predict(HmmModel model, int steps, long seed); static double modelLikelihood(HmmModel model, int[] outputSequence, boolean scaled); static double modelLikelihood(Matrix alpha, boolean scaled); static double modelLikelihood(HmmModel model, int[] outputSequence, Matrix beta, boolean scaled); static int[] decode(HmmModel model, int[] observations, boolean scaled);  }
@Test public void testModelLikelihood() { Matrix alpha = HmmAlgorithms.forwardAlgorithm(getModel(), getSequence(), false); Matrix beta = HmmAlgorithms.backwardAlgorithm(getModel(), getSequence(), false); double forwardLikelihood = HmmEvaluator.modelLikelihood(alpha, false); double backwardLikelihood = HmmEvaluator.modelLikelihood(getModel(), getSequence(), beta, false); assertEquals(forwardLikelihood, backwardLikelihood, EPSILON); assertEquals(1.8425e-4, forwardLikelihood, EPSILON); }
@Test public void testScaledModelLikelihood() { Matrix alpha = HmmAlgorithms.forwardAlgorithm(getModel(), getSequence(), true); Matrix beta = HmmAlgorithms.backwardAlgorithm(getModel(), getSequence(), true); double forwardLikelihood = HmmEvaluator.modelLikelihood(alpha, true); double backwardLikelihood = HmmEvaluator.modelLikelihood(getModel(), getSequence(), beta, true); assertEquals(forwardLikelihood, backwardLikelihood, EPSILON); assertEquals(1.8425e-4, forwardLikelihood, EPSILON); }