Package com.opengamma.analytics.math.minimization

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


    //This often fails to converge, thus the model is first fitted using price and grad, which given a point very close to the solution to use as the starting point
    final double[] temp = fitPriceAndGrad(forward, kAv, pAv, pGrad, timeToExpiry, isCall);

    final Function1D<DoubleMatrix1D, DoubleMatrix1D> func = getPriceDifferenceFunc(forward, strikes, prices, timeToExpiry, isCall);
    final Function1D<DoubleMatrix1D, DoubleMatrix2D> jac = getPriceDifferenceJac(forward, strikes, prices, timeToExpiry, isCall);
    final NonLinearTransformFunction nltf = new NonLinearTransformFunction(func, jac, TRANSFORMS);

    final DoubleMatrix1D start = TRANSFORMS.transform(new DoubleMatrix1D(temp));
    return TRANSFORMS.inverseTransform(ROOTFINDER.getRoot(nltf.getFittingFunction(), nltf.getFittingJacobian(), start)).getData();
  }
View Full Code Here


    final double vol = BlackFormulaRepository.impliedVolatility(price, forward, strike, timeToExpiry, isCall);
    final DoubleMatrix1D start = TRANSFORMS.transform(new DoubleMatrix1D(0.0, vol));

    final Function1D<DoubleMatrix1D, DoubleMatrix1D> func = getPriceGradDifferenceFunc(forward, strike, price, priceGrad, timeToExpiry, isCall);
    final Function1D<DoubleMatrix1D, DoubleMatrix2D> jac = getPriceGradJac(forward, strike, price, priceGrad, timeToExpiry, isCall);
    final NonLinearTransformFunction nltf = new NonLinearTransformFunction(func, jac, TRANSFORMS);
    return TRANSFORMS.inverseTransform(ROOTFINDER.getRoot(nltf.getFittingFunction(), nltf.getFittingJacobian(), start)).getData();
  }
View Full Code Here

    final double[] temp = fitVolatilityAndGrad(forward, kAv, volsAv, volGrad, timeToExpiry);
    final DoubleMatrix1D start = TRANSFORMS.transform(new DoubleMatrix1D(temp));

    final Function1D<DoubleMatrix1D, DoubleMatrix1D> func = getVolDifferenceFunc(forward, strikes, vols, timeToExpiry);
    final Function1D<DoubleMatrix1D, DoubleMatrix2D> jac = getVolDifferenceJac(forward, strikes, timeToExpiry);
    final NonLinearTransformFunction nltf = new NonLinearTransformFunction(func, jac, TRANSFORMS);
    return TRANSFORMS.inverseTransform(ROOTFINDER.getRoot(nltf.getFittingFunction(), nltf.getFittingJacobian(), start)).getData();
  }
View Full Code Here

      for (int i = 0; i < n - 2; i++) {
        tStrikes = Arrays.copyOfRange(strikes, i, i + 3);
        tVols = Arrays.copyOfRange(impliedVols, i, i + 3);
        final Function1D<DoubleMatrix1D, DoubleMatrix1D> func = getVolDiffFunc(forward, tStrikes, expiry, tVols);
        final Function1D<DoubleMatrix1D, DoubleMatrix2D> jac = getVolJacFunc(forward, tStrikes, expiry, beta);
        final NonLinearTransformFunction tf = new NonLinearTransformFunction(func, jac, TRANSFORM);
        final DoubleMatrix1D res = rootFinder.getRoot(tf.getFittingFunction(), tf.getFittingJacobian(), start);
        final double[] root = TRANSFORM.inverseTransform(res).getData();
        modelParams[i] = new SABRFormulaData(new double[] {root[0], beta, root[1], root[2] });
      }
    }
View Full Code Here

   * @param start The first guess at the parameter values
   * @param transform Transform from model parameters to fitting parameters, and vice versa
   * @return The LeastSquareResults
   */
  public LeastSquareResultsWithTransform solve(final DoubleMatrix1D start, final NonLinearParameterTransforms transform) {
    final NonLinearTransformFunction transFunc = new NonLinearTransformFunction(getModelValueFunction(), getModelJacobianFunction(), transform);

    final LeastSquareResults solRes = SOLVER.solve(_marketValues, _errors, transFunc.getFittingFunction(), transFunc.getFittingJacobian(),
        transform.transform(start), getConstraintFunction(transform), getMaximumStep());
    return new LeastSquareResultsWithTransform(solRes, transform);
  }
View Full Code Here

TOP

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

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.