Package com.opengamma.analytics.math.statistics.leastsquare

Examples of com.opengamma.analytics.math.statistics.leastsquare.NonLinearLeastSquare.solve()


      objective.setEndIndex(_instrumentIndex.get((loopblock + 1) * _nbInstrumentsBlock) - 1);
      // Implementation note: the index start is from the first instrument of the block and the index end is from the last instrument of the block.
      final DoubleMatrix1D observedValues = new DoubleMatrix1D(_nbInstrumentsBlock, 0.0);
      @SuppressWarnings("unused")
      final
      LeastSquareResults result = ls.solve(observedValues, getCalibrationObjective(), new DoubleMatrix1D(1.0, 0.0));
      // Implementation note: the start value is a multiplicative factor of one and an additive term of 0 (parameters unchanged).
      //   The observed values are 0 as the function returns the difference between the calculated prices and the targets.
    }
  }

View Full Code Here


      }
    };

    //TODO replace this with an explicit polynomial fitter
    final NonLinearLeastSquare ls = new NonLinearLeastSquare();
    final LeastSquareResults lsRes = ls.solve(new DoubleMatrix1D(x), new DoubleMatrix1D(impliedVols), func, new DoubleMatrix1D(0.1, 0.0, 0.0));
    final DoubleMatrix1D fitP = lsRes.getFitParameters();
    return fitP;
  }

  private void validateStrikes(final double[] strikes) {
View Full Code Here

      objective.setEndIndex(_instrumentIndex.get((loopblock + 1) * _nbInstrumentsBlock) - 1);
      // Implementation note: the index start is from the first instrument of the block and the index end is from the last instrument of the block.
      final DoubleMatrix1D observedValues = new DoubleMatrix1D(_nbInstrumentsBlock, 0.0);
      @SuppressWarnings("unused")
      final
      LeastSquareResults result = ls.solve(observedValues, _calibrationObjective, new DoubleMatrix1D(1.0, 0.0));
      // Implementation note: the start value is a multiplicative factor of one and an additive term of 0 (parameters unchanged).
      //   The observed values are 0 as the function returns the difference between the calculated prices and the targets.
    }
  }

View Full Code Here

      sigma[i] = 0.01; //1% error
    }

    final NonLinearLeastSquare ls = new NonLinearLeastSquare();
    //solve approx first
    LeastSquareResults solverRes = ls.solve(new DoubleMatrix1D(mrkVols), new DoubleMatrix1D(sigma), funcAppox, TRANSFORMS.transform(initialGuess));
    // now solve pde model
    solverRes = ls.solve(new DoubleMatrix1D(mrkVols), new DoubleMatrix1D(sigma), func, solverRes.getFitParameters());
    return new LeastSquareResultsWithTransform(solverRes, TRANSFORMS);
  }
View Full Code Here

    final NonLinearLeastSquare ls = new NonLinearLeastSquare();
    //solve approx first
    LeastSquareResults solverRes = ls.solve(new DoubleMatrix1D(mrkVols), new DoubleMatrix1D(sigma), funcAppox, TRANSFORMS.transform(initialGuess));
    // now solve pde model
    solverRes = ls.solve(new DoubleMatrix1D(mrkVols), new DoubleMatrix1D(sigma), func, solverRes.getFitParameters());
    return new LeastSquareResultsWithTransform(solverRes, TRANSFORMS);
  }

  /**
   * Transforms the price data (in PDEFullResults1D form) to implied volatility in a form used by 2D interpolator
View Full Code Here

    final double[] sigma = new double[MARKET_PRICES.length];
    Arrays.fill(sigma, 0.0001); // 1bps

    final NonLinearLeastSquare ls = new NonLinearLeastSquare();
    final LeastSquareResults lsRes = ls.solve(new DoubleMatrix1D(MARKET_VOLS), new DoubleMatrix1D(sigma), func, jac, START);

    final DoubleMatrix1D res = lsRes.getFitParameters();

    assertTrue("chi^2 too large", lsRes.getChiSq() < 0.3);
View Full Code Here

    Arrays.fill(start, NODES.length + 1, 2 * NODES.length + 1, TRANSFORMS.get(NAMES[2]).transform(0.0));
    Arrays.fill(start, 2 * NODES.length + 1, 3 * NODES.length + 1, TRANSFORMS.get(NAMES[3]).transform(0.35));
    final DoubleMatrix1D vStart = new DoubleMatrix1D(start);

    final NonLinearLeastSquare ls = new NonLinearLeastSquare();
    final LeastSquareResults lsRes = ls.solve(new DoubleMatrix1D(MARKET_VOLS), new DoubleMatrix1D(SIGMA), func, jac, vStart);

    System.out.println("CapletStrippingMarketDataTest");
    System.out.println("chi2: " + lsRes.getChiSq() + "\n");

    final SABRTermStructureParameters sabrTS = (SABRTermStructureParameters) VOL_MODEL_PROVIDER.evaluate(lsRes.getFitParameters());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.