@Test
public void testGradientAtNonInitialPoint() throws IOException {
// given
RealValueFileEventStream rvfes1 = new RealValueFileEventStream("src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt", "UTF-8");
DataIndexer testDataIndexer = new OnePassRealValueDataIndexer(rvfes1,1);
LogLikelihoodFunction objectFunction = new LogLikelihoodFunction(testDataIndexer);
// when
double[] nonInitialPoint = new double[] { 0.2, 0.5, 0.2, 0.5, 0.2,
0.5, 0.2, 0.5, 0.2, 0.5 };
double[] gradientAtNonInitialPoint =
objectFunction.gradientAt(dealignDoubleArrayForTestData(nonInitialPoint,
testDataIndexer.getPredLabels(),
testDataIndexer.getOutcomeLabels()));
double[] expectedGradient =
new double[] { -0.311616214, -0.211771052, -1.324041847, 0.93340278, 0.317407069,
0.311616214, 0.211771052, 1.324041847, -0.93340278, -0.317407069 };
// then
assertTrue(compareDoubleArray(expectedGradient, gradientAtNonInitialPoint, testDataIndexer, TOLERANCE01));