Java Apache Commons Math BicubicSplineInterpolator返回奇怪的插值

Java Apache Commons Math BicubicSplineInterpolator返回奇怪的插值,java,apache-commons-math,Java,Apache Commons Math,正在为我的输入集返回一些奇怪的结果 以下是我的测试用例: 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, 188

正在为我的输入集返回一些奇怪的结果

以下是我的测试用例:

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;
int 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++;
}   

对于上面定义的一组介于~1800和~2000之间的f值,我不确定插值集中为什么会有负值。此外,还有比输入集中的最大值大得多的值,例如257740.9296891929和249357.90724363495

我在MatLab中设置了这个输入集,用interp2立方法比较我的结果,MatLab的结果更符合我的预期。以下是MatLab中相同输入集的结果:

1915
1901.84375000034
1891.12500000000
1882.84375000020
1877
1873.59375000003
1872.62499999999
1874.09375000004
1878
1909.56249999997
1900.16796875024
1892.21875000001
1885.71484375018
1880.65625000002
1877.04296875006
1874.87500000006
1874.15234375000
1874.87499999998
1906.24999999997
1899.57812500018
1893.62500000002
1888.39062500018
1883.87500000004
1880.07812500009
1877.00000000011
1874.64062499998
1872.99999999998
1905.06250000000
1900.07421875013
1895.34374999999
1890.87109375011
1886.65624999998
1882.69921875004
1879.00000000009
1875.55859374994
1872.37500000000
1906.00000000006
1901.65625000018
1897.37500000006
1893.15625000018
1889.00000000006
1884.90625000011 
1880.87500000017
1876.90624999999
1873.00000000004
1909.06250000012
1904.32421875022
1899.71875000007
1895.24609375018
1890.90625000005
1886.69921875010
1882.62500000016
1878.68359375000
1874.87500000007
1914.25000000000
1908.07812500017
1902.37500000000
1897.14062500014
1892.37500000000
1888.07812500006
1884.25000000010
1880.89062499996
1878
1921.56250000000
1912.91796875023
1905.34375000000
1898.83984375017
1893.40625000000
1889.04296875005
1885.75000000008
1883.52734374998
1882.37500000000
1931
1918.84375000032
1908.62500000000
1900.34375000021
1894
1889.59375000005
1887.12500000004
1886.59375000001
1888
还有一点值得注意。当x和y值(如36.01或36.1)的小数点数量从3减少到2,从2减少到1时,插值结果将趋向“预期”领域(1800-2000)。负数和超大数开始消失

我正在使用commons数学库的3.3版


如果您能深入了解这些值被如此插值的原因,我们将不胜感激。谢谢。

数字之墙让人难以阅读。您已确定需要小数位数。您还可以减少正在查看的x和y值的数量吗?并可能移动数据,使x[0]==0?@Teepeemm我已将x和y值的数量从7个减少到3个,并更新了java和MatLab版本的结果。希望这能让它更容易阅读。你仍然在给我们展示一堵插值墙。如果我读对了,
interpolatorFunction.value(36,-107.99975)
是第一个放错位置的值。对吗?我们能集中精力吗?@Teepeemm是的,没错。
1915
1901.84375000034
1891.12500000000
1882.84375000020
1877
1873.59375000003
1872.62499999999
1874.09375000004
1878
1909.56249999997
1900.16796875024
1892.21875000001
1885.71484375018
1880.65625000002
1877.04296875006
1874.87500000006
1874.15234375000
1874.87499999998
1906.24999999997
1899.57812500018
1893.62500000002
1888.39062500018
1883.87500000004
1880.07812500009
1877.00000000011
1874.64062499998
1872.99999999998
1905.06250000000
1900.07421875013
1895.34374999999
1890.87109375011
1886.65624999998
1882.69921875004
1879.00000000009
1875.55859374994
1872.37500000000
1906.00000000006
1901.65625000018
1897.37500000006
1893.15625000018
1889.00000000006
1884.90625000011 
1880.87500000017
1876.90624999999
1873.00000000004
1909.06250000012
1904.32421875022
1899.71875000007
1895.24609375018
1890.90625000005
1886.69921875010
1882.62500000016
1878.68359375000
1874.87500000007
1914.25000000000
1908.07812500017
1902.37500000000
1897.14062500014
1892.37500000000
1888.07812500006
1884.25000000010
1880.89062499996
1878
1921.56250000000
1912.91796875023
1905.34375000000
1898.83984375017
1893.40625000000
1889.04296875005
1885.75000000008
1883.52734374998
1882.37500000000
1931
1918.84375000032
1908.62500000000
1900.34375000021
1894
1889.59375000005
1887.12500000004
1886.59375000001
1888