Package com.opengamma.analytics.math.minimization

Examples of com.opengamma.analytics.math.minimization.UncoupledParameterTransforms


    return new UncoupledParameterTransforms(start, DEFAULT_TRANSFORMS, fixed);
  }

  @Override
  protected NonLinearParameterTransforms getTransform(final DoubleMatrix1D start, final BitSet fixed) {
    return new UncoupledParameterTransforms(start, DEFAULT_TRANSFORMS, fixed);
  }
View Full Code Here


      Validate.isTrue(CompareUtils.closeEquals(options[i].getTimeToExpiry(), maturity),
          "All options must have the same maturity " + maturity + "; have one with maturity " + options[i].getTimeToExpiry());
      strikes[i] = options[i].getStrike();
      blackVols[i] = data[i].getBlackVolatility();
    }
    final UncoupledParameterTransforms transforms = new UncoupledParameterTransforms(new DoubleMatrix1D(initialFitParameters), TRANSFORMS, fixed);
    final EuropeanVanillaOption atmOption = new EuropeanVanillaOption(forward, maturity, true);
    final ParameterizedFunction<Double, DoubleMatrix1D, Double> function = new ParameterizedFunction<Double, DoubleMatrix1D, Double>() {

      @SuppressWarnings("synthetic-access")
      @Override
      public Double evaluate(final Double strike, final DoubleMatrix1D fp) {
        final DoubleMatrix1D mp = transforms.inverseTransform(fp);
        double alpha = mp.getEntry(0);
        final double beta = mp.getEntry(1);
        final double rho = mp.getEntry(2);
        final double nu = mp.getEntry(3);

        final SABRFormulaData sabrFormulaData;
        if (recoverATMVol) {
          alpha = _atmCalculator.calculate(new SABRFormulaData(alpha, beta, rho, nu), atmOption, forward, atmVol);
          sabrFormulaData = new SABRFormulaData(alpha, beta, rho, nu);
        } else {
          sabrFormulaData = new SABRFormulaData(alpha, beta, rho, nu);
        }
        final EuropeanVanillaOption option = new EuropeanVanillaOption(strike, maturity, true);
        return _formula.getVolatilityFunction(option, forward).evaluate(sabrFormulaData);
      }
    };

    final DoubleMatrix1D fp = transforms.transform(new DoubleMatrix1D(initialFitParameters));
    LeastSquareResults lsRes = errors == null ? SOLVER.solve(new DoubleMatrix1D(strikes), new DoubleMatrix1D(blackVols), function, fp)
        : SOLVER.solve(new DoubleMatrix1D(strikes), new DoubleMatrix1D(blackVols), new DoubleMatrix1D(errors), function, fp);
    final double[] mp = transforms.inverseTransform(lsRes.getFitParameters()).toArray();
    if (recoverATMVol) {
      final double beta = mp[1];
      final double nu = mp[2];
      final double rho = mp[3];
      final EuropeanVanillaOption option = new EuropeanVanillaOption(forward, maturity, true);
View Full Code Here

  }

  @Override
  protected NonLinearParameterTransforms getTransform(final DoubleMatrix1D start) {
    final BitSet fixed = new BitSet();
    return new UncoupledParameterTransforms(start, _transforms, fixed);
  }
View Full Code Here

    return new UncoupledParameterTransforms(start, _transforms, fixed);
  }

  @Override
  protected NonLinearParameterTransforms getTransform(final DoubleMatrix1D start, final BitSet fixed) {
    return new UncoupledParameterTransforms(start, _transforms, fixed);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.math.minimization.UncoupledParameterTransforms

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.