Package com.opengamma.analytics.math.function

Examples of com.opengamma.analytics.math.function.DoubleFunction1D.evaluate()


    final DoubleFunction1D derivative = pair.getSecond();
    for (int i = 0; i < mid; i++) {
      final double root = ROOT_FINDER.getRoot(function, derivative, getInitialRootGuess(i, n));
      x[i] = -root;
      x[n - i - 1] = root;
      final double dp = derivative.evaluate(root);
      w[i] = 2 / ((1 - root * root) * dp * dp);
      w[n - i - 1] = w[i];
    }
    return new GaussianQuadratureData(x, w);
  }
View Full Code Here


    final DoubleFunction1D derivative = pair.getSecond();
    double root = 0;
    for (int i = 0; i < m; i++) {
      root = getInitialRootGuess(root, i, n, x);
      root = ROOT_FINDER.getRoot(function, derivative, root);
      final double dp = derivative.evaluate(root);
      x[i] = -root;
      x[n - 1 - i] = root;
      w[i] = 2. / (dp * dp);
      w[n - 1 - i] = w[i];
    }
View Full Code Here

    final double[] w = new double[n];
    double root = 0;
    for (int i = 0; i < n; i++) {
      root = ROOT_FINDER.getRoot(function, derivative, getInitialRootGuess(root, i, n, x));
      x[i] = root;
      w[i] = -GAMMA_FUNCTION.evaluate(_alpha + n) / MathUtils.factorialDouble(n) / (derivative.evaluate(root) * p1.evaluate(root));
    }
    return new GaussianQuadratureData(x, w);
  }

  private double getInitialRootGuess(final double previousRoot, final int i, final int n, final double[] x) {
View Full Code Here

      final double d = 2 * n + _c;
      root = getInitialRootGuess(root, i, n, x);
      root = ROOT_FINDER.getRoot(function, derivative, root);
      x[i] = root;
      w[i] = GAMMA_FUNCTION.evaluate(_alpha + n) * GAMMA_FUNCTION.evaluate(_beta + n) / MathUtils.factorialDouble(n) / GAMMA_FUNCTION.evaluate(n + _c + 1) * d * Math.pow(2, _c)
          / (derivative.evaluate(root) * previous.evaluate(root));
    }
    return new GaussianQuadratureData(x, w);
  }

  private double getInitialRootGuess(final double previousRoot, final int i, final int n, final double[] x) {
View Full Code Here

      }
    };
    assertEquals(l1[0].evaluate(x), f0.evaluate(x), EPS);
    assertEquals(l1[1].evaluate(x), f1.evaluate(x), EPS);
    assertEquals(l1[2].evaluate(x), f2.evaluate(x), EPS);
    assertEquals(l1[3].evaluate(x), f3.evaluate(x), EPS);
  }

  @Test
  public void testAlpha2() {
    final int n = 14;
View Full Code Here

    double[] xValues = new double[nPts];
    double[] yValues = new double[nPts];

    for (int i = 0; i < nPts; ++i) {
      xValues[i] = -5. + 10 * i / (nPts - 1);
      yValues[i] = func.evaluate(xValues[i]);
    }

    double[] yValuesNorm = new double[nPts];

    final double mean = _meanCal.evaluate(xValues);
View Full Code Here

    final double std = _stdCal.evaluate(xValues);
    final double ratio = mean / std;

    for (int i = 0; i < nPts; ++i) {
      final double tmp = xValues[i] / std - ratio;
      yValuesNorm[i] = func.evaluate(tmp);
    }

    /**
     * Tests for regress(..)
     */
 
View Full Code Here

    final double[] residuals = result.getResiduals();
    func = new RealPolynomialFunction1D(coeffResult);
    double[] yValuesFit = new double[nPts];
    for (int i = 0; i < nPts; ++i) {
      yValuesFit[i] = func.evaluate(xValues[i]);
    }

    for (int i = 0; i < nPts; ++i) {
      assertEquals(Math.abs(yValuesFit[i] - yValues[i]), 0., Math.abs(yValues[i]) * EPS);
    }
View Full Code Here

    PolynomialsLeastSquaresFitterResult resultVer = regObj.regressVerbose(xValues, yValues, degree, false);
    coeffResult = resultVer.getCoeff();
    func = new RealPolynomialFunction1D(coeffResult);
    for (int i = 0; i < nPts; ++i) {
      yValuesFit[i] = func.evaluate(xValues[i]);
    }

    assertEquals(nPts - (degree + 1), resultVer.getDof(), 0);
    for (int i = 0; i < degree + 1; ++i) {
      assertEquals(coeff[i], coeffResult[i], EPS * Math.abs(coeff[i]));
 
View Full Code Here

    }

    func = new RealPolynomialFunction1D(coeffResult);
    for (int i = 0; i < nPts; ++i) {
      final double tmp = xValues[i] / std - ratio;
      yValuesFit[i] = func.evaluate(tmp);
    }

    for (int i = 0; i < nPts; ++i) {
      assertEquals(Math.abs(yValuesFit[i] - yValuesNorm[i]), 0., Math.abs(yValuesNorm[i]) * EPS);
    }
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.