Package com.opengamma.analytics.math.function

Examples of com.opengamma.analytics.math.function.RealPolynomialFunction1D


    out.println(Arrays.toString(coefficients));
  }

  // @export "rootFindingDemo"
  public static void rootFindingDemo(final PrintStream out) {
    final RealPolynomialFunction1D f = getFunction();

    final CubicRealRootFinder cubic = new CubicRealRootFinder();
    final java.lang.Double[] roots = cubic.getRoots(f);
    out.println(Arrays.toString(roots));
View Full Code Here


    }

    @Override
    public Double evaluate(final Double x) {
      @SuppressWarnings("synthetic-access")
      final CapFloorCMSSpreadSABRBinormalMethod method = new CapFloorCMSSpreadSABRBinormalMethod(new RealPolynomialFunction1D(new double[] {x }), _methodCmsCap, _methodCmsCoupon);
      return method.presentValue(_cmsSpread, _sabrData).getAmount() - _price;
    }
View Full Code Here

    final double a1 = 1 + (2 - 3 * rho * rho) * ksi * ksi * t / 24;
    final double a2 = rho * beta * ksi * t / 4 / f1;
    final double a3 = beta1 * beta1 * t / 24 / f1 / f1;
    Double[] roots;
    if (CompareUtils.closeEquals(a3, 0, 1e-16)) {
      roots = QUADRATIC_FINDER.getRoots(new RealPolynomialFunction1D(new double[] {a0, a1, a2}));
    } else {
      roots = ROOT_FINDER.getRoots(new RealPolynomialFunction1D(new double[] {a0, a1, a2, a3}));
    }
    Arrays.sort(roots);
    if (roots[0] > 0) {
      return data.withAlpha(roots[0]);
    }
View Full Code Here

    }

    @Override
    public Double evaluate(final Double x) {
      @SuppressWarnings("synthetic-access")
      final CapFloorCMSSpreadSABRBinormalMethod method = new CapFloorCMSSpreadSABRBinormalMethod(new RealPolynomialFunction1D(new double[] {x}), _methodCmsCap, _methodCmsCoupon);
      return method.presentValue(_cmsSpread, _sabrData).getAmount(_cmsSpread.getCurrency()) - _price;
    }
View Full Code Here

    final double[] xData = getKeys();
    final double[] yData = getValues();
    final int n = xData.length - 1;
    if (n == 0) {
      final double a = yData[0];
      return new RealPolynomialFunction1D[] {new RealPolynomialFunction1D(a) };
    } else if (n == 1) {
      final double a = yData[1];
      final double b = (yData[1] - yData[0]) / (xData[1] - xData[0]);
      return new RealPolynomialFunction1D[] {new RealPolynomialFunction1D(a, b) };
    } else {
      final RealPolynomialFunction1D[] quadratic = new RealPolynomialFunction1D[n - 1];
      for (int i = 1; i < n; i++) {
        quadratic[i - 1] = getQuadratic(xData, yData, i);
      }
View Full Code Here

  private RealPolynomialFunction1D[] getQuadraticsFirstDerivative() {
    final double[] xData = getKeys();
    final double[] yData = getValues();
    final int n = xData.length - 1;
    if (n == 0) {
      return new RealPolynomialFunction1D[] {new RealPolynomialFunction1D(0.) };
    } else if (n == 1) {
      final double b = (yData[1] - yData[0]) / (xData[1] - xData[0]);
      return new RealPolynomialFunction1D[] {new RealPolynomialFunction1D(b) };
    } else {
      final RealPolynomialFunction1D[] quadraticFirstDerivative = new RealPolynomialFunction1D[n - 1];
      for (int i = 1; i < n; i++) {
        quadraticFirstDerivative[i - 1] = getQuadraticFirstDerivative(xData, yData, i);
      }
View Full Code Here

    final double dx2 = x[index + 1] - x[index];
    final double dy1 = y[index] - y[index - 1];
    final double dy2 = y[index + 1] - y[index];
    final double b = (dx1 * dy2 / dx2 + dx2 * dy1 / dx1) / (dx1 + dx2);
    final double c = (dy2 / dx2 - dy1 / dx1) / (dx1 + dx2);
    return new RealPolynomialFunction1D(new double[] {a, b, c });
  }
View Full Code Here

    final double dx2 = x[index + 1] - x[index];
    final double dy1 = y[index] - y[index - 1];
    final double dy2 = y[index + 1] - y[index];
    final double b = (dx1 * dy2 / dx2 + dx2 * dy1 / dx1) / (dx1 + dx2);
    final double c = (dy2 / dx2 - dy1 / dx1) / (dx1 + dx2);
    return new RealPolynomialFunction1D(new double[] {b, 2. * c });
  }
View Full Code Here

  }

  @Test
  public void getter() {
    final double correlation = 0.80;
    final DoubleFunction1D correlationFunction = new RealPolynomialFunction1D(new double[] {correlation }); // Constant function
    final CapFloorCMSSpreadSABRBinormalMethod method = new CapFloorCMSSpreadSABRBinormalMethod(correlationFunction, METHOD_CMS_CAP, METHOD_CMS_COUPON);
    assertEquals("CMS spread binormal method: correlation function getter", correlationFunction, method.getCorrelation());
  }
View Full Code Here

  /**
   * Tests the present value against the price explicitly computed for constant correlation.
   */
  public void presentValue() {
    final double correlation = 0.80;
    final DoubleFunction1D correlationFunction = new RealPolynomialFunction1D(new double[] {correlation }); // Constant function
    final CapFloorCMSSpreadSABRBinormalMethod method = new CapFloorCMSSpreadSABRBinormalMethod(correlationFunction, METHOD_CMS_CAP, METHOD_CMS_COUPON);
    final double cmsSpreadPrice = method.presentValue(CMS_CAP_SPREAD, SABR_BUNDLE).getAmount();
    final double discountFactorPayment = CURVES.getCurve(FUNDING_CURVE_NAME).getDiscountFactor(PAYMENT_TIME);
    final CouponCMSSABRReplicationMethod methodCms = CouponCMSSABRReplicationMethod.getInstance();
    final CapFloorCMSSABRReplicationMethod methodCmsCap = CapFloorCMSSABRReplicationMethod.getDefaultInstance();
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.math.function.RealPolynomialFunction1D

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.