[
https://issues.apache.org/jira/browse/MATH-1138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14159799#comment-14159799
]
Hank Grabowski commented on MATH-1138:
--------------------------------------
That said, the spline interpolator is not returning correct values for the
Bicubic test data set. For example, given:
xi = [ 3.0000 4.0000 5.0000 6.5000 ];
zi = [ 25.000 47.000 73.000 119.500];
The correct value of the interpolation of z for x = 4.5 is 59.5. The spline
interpolator in Apache Math is returning 59.388... . I'll continue to
investigate this this week. The accuracy of my implementation will not be
correct until I figure out why spline is not working right.
Another note, TricubicSplineInterpolator was dependent on the partial
derivatives in the original BicubicSplineInterpolatingFunction. There is no
such thing in this implementation therefore TricubicSpline will need to be
implemented as a piece-wise spline based on the 2D spline, in the same way that
the 2D spline is based on the piece-wise implementation based on the 1D spline.
> BicubicSplineInterpolator is returning incorrect interpolated values
> --------------------------------------------------------------------
>
> Key: MATH-1138
> URL: https://issues.apache.org/jira/browse/MATH-1138
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 3.3
> Reporter: Adam Bedrossian
> Attachments: Interpolated Values from CM and MatLab.docx
>
>
> 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.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)