public void LogBackwardTest2()
{
double[][][] observations;
int[] labels;
var hmm = IndependentMarkovFunctionTest.CreateModel3(out observations, out labels);
MarkovMultivariateFunction function = new MarkovMultivariateFunction(hmm);
foreach (double[][] x in observations)
{
foreach (int y in labels)
{
double[,] actual = new double[x.Length, 5];
Accord.Statistics.Models.Fields.
ForwardBackwardAlgorithm.LogBackward(function.Factors[y], x, y, actual);
double[,] expected = new double[x.Length, 5];
Accord.Statistics.Models.Markov.
ForwardBackwardAlgorithm.LogBackward(hmm.Models[y], x, expected);
for (int i = 0; i < actual.GetLength(0); i++)
for (int j = 0; j < actual.GetLength(1); j++)
{
Assert.AreEqual(expected[i, j], actual[i, j], 1e-10);
Assert.IsFalse(Double.IsNaN(actual[i, j]));
}
}
}
}