public void BackwardTest2()
{
HiddenMarkovModel hmm = CreateModel3();
// L L R R
int[] observations = { 0, 0, 1, 1 };
double[,] actual = ForwardBackwardAlgorithm.Backward(hmm, observations);
// Backward matrices from R's HMM package are
// transposed in relation to the framework's:
Assert.AreEqual(4, actual.GetLength(0));
Assert.AreEqual(2, actual.GetLength(1));
Assert.AreEqual(0.128982144, actual[0, 0], 1e-10);
Assert.AreEqual(0.082407504, actual[0, 1], 1e-10);
Assert.AreEqual(0.196816, actual[1, 0], 1e-10);
Assert.AreEqual(0.453856, actual[1, 1], 1e-10);
Assert.AreEqual(0.376, actual[2, 0], 1e-10);
Assert.AreEqual(0.691, actual[2, 1], 1e-10);
Assert.AreEqual(1, actual[3, 0]);
Assert.AreEqual(1, actual[3, 1]);
foreach (double p in actual)
Assert.IsFalse(double.IsNaN(p));
}