[ https://issues.apache.org/jira/browse/MATH1138?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=14137174#comment14137174
]
Hank Grabowski commented on MATH1138:

Actually, the source they used for that derivation was not that link, but this one (also in
their references section):
http://www.geovista.psu.edu/sites/geocomp99/Gc99/082/gc_082.htm
You can see in Section 3.8 how they are sampling just the corner points (0,0), (1,0), (0,1)
and (1,1) in determining coefficients, just like their derivation. The reference you cited
is sampling a 4x4 grid, which makes more sense to me. The methodology I was talking about
existing in the Octave code is the same as the methodology in his site as well. Specifically,
to do a 2D interpolation you call a series of 1D interpolations. The coefficient term version
at the bottom of the reference you cited is useful for when the region being sampled between
iterations often stays the same.
I am aware that Octave uses GPL, which is not compatible with the Apache license, so I was
not going to be using their code (it is written in Matlab scripting language and FORTRAN
too). I was simply looking at which math algorithm they chose to use. I did not want to
use the code off of the site you listed as a baseline either because there is no mention of
licensing rights at all. It simply says, "Anything at this page may be copied and modified."
but it doesn't list what the requirements are for when you do that.
My implementation strategy was going to be as follows: I was therefore going to be implementing
the algorithm using existing Apache Math 1D interpolation functions after I created my own
validating implementation in Octave source code and a test set of data in Octave as well.
I would then create versions of the test that does random samplings of the interpolation
region in Octave to figure out what the statistical distributions of errors are. I would
then use that for the tolerances of the same test implementation in Apache.
I believe the public API for this should be fine, but I will not change it without consulting
team members here. I would also like to implement lower order BivariateGridInterpolators.
This can be overkill for a lot of applications. That would be done in a seperate story/issue
though.
> BicubicSplineInterpolator is returning incorrect interpolated values
> 
>
> Key: MATH1138
> URL: https://issues.apache.org/jira/browse/MATH1138
> 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)
