“无效的输入数据"来自SciPy的三次样条插值过程;来自interpolate.bisplrep的不良结果? [英] "Invalid input data" from SciPy's cublic spline interpolation process; bad results from interpolate.bisplrep?

查看:318
本文介绍了“无效的输入数据"来自SciPy的三次样条插值过程;来自interpolate.bisplrep的不良结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用scipy.interpolate.bisplrep和scipy.interpolate.bisplev基于少量已知差异对两个数据集之间的差异进行2D回归.代码是:

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)

运行此命令时,bisplev会引发难以理解的异常"ValueError:无效的输入数据",这是从基础_fitpack._bisplev函数返回的错误代码响应的.我对样条线了解得还不够多,以至于不知道什么是对样条线的无效描述,但是我确实查看了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]

让我印象深刻的是,表示样条中结"的前两个元素是八个元素,仅包含两个唯一的值,每个值重复四次.这两个唯一值都来自相应的diffPoints列表,但是diffPoints都是16个唯一元素.

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 .

推荐答案

根据我过去对该问题的经验,必须按升序对features[0]features[1]进行排序,以使bisplev正常工作.

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

这篇关于“无效的输入数据"来自SciPy的三次样条插值过程;来自interpolate.bisplrep的不良结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆