Package com.opengamma.analytics.math.interpolation.data

Examples of com.opengamma.analytics.math.interpolation.data.RadialBasisFunctionInterpolatorDataBundle


  @Override
  public Double interpolate(final InterpolatorNDDataBundle data, final double[] x) {
    validateInput(data, x);
    ArgumentChecker.isTrue(data instanceof RadialBasisFunctionInterpolatorDataBundle, "RadialBasisFunctionInterpolatorND needs a RadialBasisFunctionInterpolatorDataBundle");
    final RadialBasisFunctionInterpolatorDataBundle radialData = (RadialBasisFunctionInterpolatorDataBundle) data;
    final List<Pair<double[], Double>> rawData = radialData.getData();
    final double[] w = radialData.getWeights();
    final Function1D<Double, Double> basisFunction = radialData.getBasisFunction();
    final int n = rawData.size();
    double sum = 0;
    double normSum = 0;
    double[] xi;
    double phi;
    for (int i = 0; i < n; i++) {
      xi = rawData.get(i).getFirst();
      phi = basisFunction.evaluate(DistanceCalculator.getDistance(x, xi));
      sum += w[i] * phi;
      normSum += phi;
    }

    return radialData.isNormalized() ? sum / normSum : sum;
  }
View Full Code Here


  @Override
  public Map<double[], Double> getNodeSensitivitiesForValue(final InterpolatorNDDataBundle data, final double[] x) {
    ArgumentChecker.notNull(data, "data");
    ArgumentChecker.notNull(x, "x array");
    ArgumentChecker.isTrue(data instanceof RadialBasisFunctionInterpolatorDataBundle, "RadialBasisFunctionInterpolatorNDSensitivityCalculator needs a RadialBasisFunctionInterpolatorDataBundle");
    final RadialBasisFunctionInterpolatorDataBundle radialData = (RadialBasisFunctionInterpolatorDataBundle) data;
    final List<Pair<double[], Double>> rawData = radialData.getData();
    final Function1D<Double, Double> basisFunction = radialData.getBasisFunction();
    final int n = rawData.size();
    double[] xi;
    final double[] phi = new double[n];
    double normSum = 0;
    final double[] phiNorm = new double[n];
    for (int i = 0; i < n; i++) {
      xi = rawData.get(i).getFirst();
      phi[i] = basisFunction.evaluate(DistanceCalculator.getDistance(x, xi));

      if (radialData.isNormalized()) {
        normSum += phi[i];

        double sum = 0;
        double[] xj;
        for (int j = 0; j < n; j++) {
          xj = rawData.get(j).getFirst();
          sum += basisFunction.evaluate(DistanceCalculator.getDistance(xj, xi));
        }
        phiNorm[i] = sum;
      }
    }
    final double[] temp = radialData.getDecompositionResult().solve(phi);
    double sense = 0;
    final Map<double[], Double> res = new HashMap<>(n);
    for (int i = 0; i < n; i++) {
      if (radialData.isNormalized()) {
        sense = temp[i] * phiNorm[i] / normSum;
      } else {
        sense = temp[i];
      }
      res.put(rawData.get(i).getFirst(), sense);
View Full Code Here

    return res;

  }
  @Override
  public RadialBasisFunctionInterpolatorDataBundle getDataBundle(final double[] x, final double[] y, final double[] z, final double[] values) {
    return new RadialBasisFunctionInterpolatorDataBundle(transformData(x, y, z, values), _basisFunction, _useNormalized);
  }
View Full Code Here

    return new RadialBasisFunctionInterpolatorDataBundle(transformData(x, y, z, values), _basisFunction, _useNormalized);
  }

  @Override
  public RadialBasisFunctionInterpolatorDataBundle getDataBundle(final List<Pair<double[], Double>> data) {
    return new RadialBasisFunctionInterpolatorDataBundle(data, _basisFunction, _useNormalized);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.math.interpolation.data.RadialBasisFunctionInterpolatorDataBundle

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.