背景
在对一个缺失值的表格进行插值时,选取了拉格朗日插值法,该方法选取缺失值的点周围的点进行插值计算。笔者首先选取缺失点前后5个点进行运算,小部分点满足插值要求,大部分不符合要求,减少点数为前后4、3、2个点后,全部满足要求,继续增加点数至6、7个点,数据大大超出了附近点的值,甚至出现超大负值。
原因
笔者使用的是python3的第三方库scipy,查看github上源代码,有警告提示:
Warning: This implementation is numerically unstable. Do not expect to
be able to use more than about 20 points even if they are chosen optimally.
可见点数不能过多。