SVINonLinearLeastSquareFitter extends LeastSquareSmileFitter { @Override public LeastSquareResultsWithTransform getFitResult(final EuropeanVanillaOption[] options, final BlackFunctionData[] data, final double[] initialFitParameters, final BitSet fixed) { return getFitResult(options, data, null, initialFitParameters, fixed); } SVINonLinearLeastSquareFitter();  SVINonLinearLeastSquareFitter(final NonLinearLeastSquare solver); @Override LeastSquareResultsWithTransform getFitResult(final EuropeanVanillaOption[] options, final BlackFunctionData[] data, final double[] initialFitParameters, final BitSet fixed); @Override LeastSquareResultsWithTransform getFitResult(final EuropeanVanillaOption[] options, final BlackFunctionData[] data, final double[] errors, final double[] initialFitParameters,
      final BitSet fixed);  }
@Test public void testSolutionFlatSurface() { final LeastSquareResultsWithTransform results = FITTER.getFitResult(OPTIONS, FLAT_DATA, ERRORS, INITIAL_VALUES, FIXED); final DoubleMatrix1D parameters = results.getModelParameters(); assertEquals("a", SIGMA * SIGMA, parameters.getEntry(0), EPS); assertEquals("b", 0.0, parameters.getEntry(1), EPS); }
@Test public void testRecoverParameters() { LeastSquareResultsWithTransform results = FITTER.getFitResult(OPTIONS, SMILE_DATA, INITIAL_VALUES, FIXED); DoubleMatrix1D fit = results.getModelParameters(); final double eps = ERRORS[0]; assertEquals("a", SVI_DATA.getA(), fit.getEntry(0), eps); assertEquals("b", SVI_DATA.getB(), fit.getEntry(1), eps); assertEquals("rho", SVI_DATA.getRho(), fit.getEntry(2), eps); assertEquals("sigma", SVI_DATA.getNu(), fit.getEntry(3), eps * 100); assertEquals("m", SVI_DATA.getM(), fit.getEntry(4), eps); final double chiSq = results.getChiSq(); assertEquals("chi^2", 0, chiSq, eps * eps); results = FITTER.getFitResult(OPTIONS, SMILE_DATA, ERRORS, INITIAL_VALUES, FIXED); fit = results.getModelParameters(); assertEquals(SVI_DATA.getA(), fit.getEntry(0), eps); assertEquals(SVI_DATA.getB(), fit.getEntry(1), eps); assertEquals(SVI_DATA.getRho(), fit.getEntry(2), eps); assertEquals(SVI_DATA.getNu(), fit.getEntry(3), eps * 100); assertEquals(SVI_DATA.getM(), fit.getEntry(4), eps); assertEquals(results.getChiSq() * eps * eps, chiSq, eps); }