“Invalid input data” from SciPy's cublic spline interpolation process; bad results from interpolate.bisplrep?

泪湿孤枕 提交于 2020-05-29 08:32:10

问题


I'm attempting to use scipy.interpolate.bisplrep and scipy.interpolate.bisplev to perform a 2D regression on the differences between two datasets, based on a small set of known differences. The code is:

splineRT = interp.bisplrep(diffPoints[0], diffPoints[1], RTdiffs)
allDiffs = interp.bisplev(features[0], features[1], splineRT)

When I run this, bisplev throws the inscrutable exception "ValueError: Invalid input data", which is in response from an error code returned from the underlying _fitpack._bisplev function. I don't know nearly enough about splines to know what qualifies as an invalid description of one, but I did look at the value of splineRT, which is:

[array([ 367.51732902,  367.51732902,  367.51732902,  367.51732902,
        911.4739006 ,  911.4739006 ,  911.4739006 ,  911.4739006 ]),
 array([ 1251.8868,  1251.8868,  1251.8868,  1251.8868,  1846.2027,
        1846.2027,  1846.2027,  1846.2027]),
 array([ -1.36687935e+04,   3.78197089e+04,  -6.83863404e+04,
        -7.25568790e+04,   4.90004158e+04,  -1.11701213e+05,
         2.02854711e+05,  -1.67569797e+05,  -7.22174063e+04,
         1.27574330e+05,  -2.33080009e+05,   2.80073578e+05,
         3.37054374e+04,   1.89380033e+04,  -1.81027026e+04,
        -2.51210000e+00]),
 3,
 3]

What strikes me is that the first two elements, which signify the "knots" in the spline, are eight elements, consisting of only two unique values repeated four times each. Both unique values are from the corresponding diffPoints lists, but diffPoints are both 16 unique elements.

What's going on here? And/or is the problem this or something else? Any assistance is appreciated.

EDIT: Here's a transcript of the bug (?) in action, start-to-finish: https://www.dropbox.com/s/w758s7racfy9q4s/interpolationBug.txt .


回答1:


From my past experience with this problem, features[0] and features[1] must be sorted in ascending order for bisplev to work.



来源:https://stackoverflow.com/questions/22082881/invalid-input-data-from-scipys-cublic-spline-interpolation-process-bad-resul

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!