@Test public final void testGradient() { double[] pos = new double[2]; // dG/dA for (int i = 0; i < X.length; i++) { pos[0] = X[i]; pos[1] = Y[i]; assertEquals( "Bad accuracy for x=" + pos[0] + ", y=" + pos[1] + " in dG/dA value.", val[i] / params[2], g.grad(pos, params, 2), TOLERANCE); } // dG/dx0 for (int i = 0; i < X.length; i++) { pos[0] = X[i]; pos[1] = Y[i]; assertEquals( "Bad accuracy for x=" + pos[0] + ", y=" + pos[1] + " in dG/dx0 value.", dgdx0_val[i], g.grad(pos, params, 0), TOLERANCE); } // dG/dy0 for (int i = 0; i < X.length; i++) { pos[0] = X[i]; pos[1] = Y[i]; assertEquals( "Bad accuracy for x=" + pos[0] + ", y=" + pos[1] + " in dG/dy0 value.", dgdy0_val[i], g.grad(pos, params, 1), TOLERANCE); } // dG/db for (int i = 0; i < X.length; i++) { pos[0] = X[i]; pos[1] = Y[i]; assertEquals( "Bad accuracy for x=" + pos[0] + ", y=" + pos[1] + " in dG/db value.", dgdb_val[i], g.grad(pos, params, 3), 1e2 * TOLERANCE); } }