// System.out.println("z: " + z);
}
@Test
public void smallPertubationTest() {
final MatrixAlgebra ma = new OGMatrixAlgebra();
final double[] dy = new double[20];
for (int i = 0; i < 20; i++) {
dy[i] = 0.1 * SIGMA.getEntry(i) * NORMAL.nextRandom();
}
final DoubleMatrix1D deltaY = new DoubleMatrix1D(dy);
final DoubleMatrix1D solution = new DoubleMatrix1D(new double[] {1.0, 1.0, 0.0, 0.0 });
final NonLinearLeastSquare ls = new NonLinearLeastSquare();
final DoubleMatrix2D res = ls.calInverseJacobian(SIGMA, FUNCTION, GRAD, solution);
// System.out.println("invese Jac: " + res);
final DoubleMatrix1D deltaParms = (DoubleMatrix1D) ma.multiply(res, deltaY);
// System.out.println("delta parms: " + deltaParms);
final DoubleMatrix1D y = (DoubleMatrix1D) ma.add(Y, deltaY);
final LeastSquareResults lsRes = ls.solve(X, y, SIGMA, PARAM_FUNCTION, PARAM_GRAD, solution);
final DoubleMatrix1D trueDeltaParms = (DoubleMatrix1D) ma.subtract(lsRes.getFitParameters(), solution);
// System.out.println("true delta parms: " + trueDeltaParms);
assertEquals(trueDeltaParms.getEntry(0), deltaParms.getEntry(0), 5e-5);
assertEquals(trueDeltaParms.getEntry(1), deltaParms.getEntry(1), 5e-5);
assertEquals(trueDeltaParms.getEntry(2), deltaParms.getEntry(2), 5e-5);