[ 
https://issues.apache.org/jira/browse/MATH-1138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14175966#comment-14175966
 ] 

Hank Grabowski commented on MATH-1138:
--------------------------------------

We can go back to only requiring for elements if we use the regular spline 
instead of the Akima spline.  The tolerances on the interpolation tests will 
have to be significantly loosened however since the regular spline algorithm 
produces larger deviations from the truth function by the nature of the 
algorithm.  I was opting for the increased accuracy.  In a future revision we 
were considering giving people the option to select their interpolation method 
between regular, Akima and B-Spline.  I just haven't gotten around to coding 
that.  Perhaps now would be a good time.  We could default to the regular 
spline and give people the Akima spline option, noting that it is of higher 
accuracy.  I do not know what the minimum number of points for the B-spline 
will be as I haven't started investigating an implementation yet.  It may be 
that too is four and thus once all is said and done the default spline 
algorithm would always be four.

> 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
>             Fix For: 3.4
>
>         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)

Reply via email to