CapFloorCMSSpreadSABRBinormalMethod { public double impliedCorrelation(final CapFloorCMSSpread cmsSpread, final SABRSwaptionProviderInterface sabrData, final double price) { final SolveCorrelation function = new SolveCorrelation(cmsSpread, sabrData, price); final BrentSingleRootFinder finder = new BrentSingleRootFinder(); final double correlation = finder.getRoot(function, -0.999, 0.999); return correlation; } CapFloorCMSSpreadSABRBinormalMethod(final DoubleFunction1D correlation, final CapFloorCMSSABRReplicationAbstractMethod methodCmsCap,
      final CouponCMSSABRReplicationGenericMethod methodCmsCoupon); DoubleFunction1D getCorrelation(); MultipleCurrencyAmount presentValue(final CapFloorCMSSpread cmsSpread, final SABRSwaptionProviderInterface sabrData); double impliedCorrelation(final CapFloorCMSSpread cmsSpread, final SABRSwaptionProviderInterface sabrData, final double price); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final CapFloorCMSSpread cmsSpread, final SABRSwaptionProviderInterface sabrData); PresentValueSABRSensitivityDataBundle presentValueSABRSensitivity(final CapFloorCMSSpread cmsSpread, final SABRSwaptionProviderInterface sabrData);  }
@Test public void impliedCorrelation() { final double[] correlation = new double[] {-0.50, 0.00, 0.50, 0.75, 0.80, 0.85, 0.90, 0.95, 0.99}; final int nbCor = correlation.length; final double[] impliedCorrelation = new double[nbCor]; for (int loopcor = 0; loopcor < nbCor; loopcor++) { final DoubleFunction1D correlationFunction = new RealPolynomialFunction1D(new double[] {correlation[loopcor]}); final CapFloorCMSSpreadSABRBinormalMethod method = new CapFloorCMSSpreadSABRBinormalMethod(correlationFunction, METHOD_CMS_CAP, METHOD_CMS_COUPON); final double cmsSpreadPrice = method.presentValue(CMS_CAP_SPREAD, SABR_MULTICURVES).getAmount(EUR); impliedCorrelation[loopcor] = method.impliedCorrelation(CMS_CAP_SPREAD, SABR_MULTICURVES, cmsSpreadPrice); assertEquals("CMS spread cap/floor: implied correlation", correlation[loopcor], impliedCorrelation[loopcor], 1.0E-10); } }