Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-1138

BicubicSplineInterpolator is returning incorrect interpolated values

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.3
    • 3.4
    • None
    • None

    Description

      I have encountered a use case with the BicubicSplineInterpolator where the interpolated values that are being returned seem incorrect. Furthermore, the values do not match those generated by MatLab using the interp2 'cubic' method.

      Here is a snippet of code that uses the interpolator:

      double[] xValues = new double[]

      {36, 36.001, 36.002}

      ;
      double[] yValues = new double[] {-108.00, -107.999, -107.998};

      double[][] fValues = new double[][] {{1915, 1906, 1931},

      {1877, 1889, 1894}

      ,
      {1878, 1873, 1888}};

      BicubicSplineInterpolator interpolator = new BicubicSplineInterpolator();
      BicubicSplineInterpolatingFunction interpolatorFunction = interpolator.interpolate(xValues, yValues, fValues);

      double[][] results = new double[9][9];
      double x = 36;
      int arrayIndexX = 0, arrayIndexY = 0;

      while(x <= 36.002) {
      double y = -108;
      arrayIndexY = 0;
      while (y <= -107.998)

      { results[arrayIndexX][arrayIndexY] = interpolatorFunction.value(x, y); System.out.println(results[arrayIndexX][arrayIndexY]); y = y + 0.00025; arrayIndexY++; }

      x = x + 0.00025;
      arrayIndexX++;
      }

      Attached is a grid showing x and y values and the corresponding interpolated value from both commons math and MatLab.

      The values produced by commons math are far off from those created by MatLab.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              abedrossian Adam Bedrossian
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: