如何计算python中使用的平滑条件interpolate.splrep?

2024-04-26 17:34:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用scipy的interpolate.splrep来拟合时间序列。然而,我不知道如何确定一个有效的平滑条件,而不手动调整它的眼睛。似乎应该有一种方法来计算这个条件。在

根据docs,平滑条件应按如下方式确定:

Recommended values of s depend on the weights, w. If the weights represent the inverse of the standard-deviation of y, then a good s value should be found in the range (m-sqrt(2*m),m+sqrt(2*m)) where m is the number of datapoints in x, y, and w. default : s=m-sqrt(2*m) if weights are supplied. s = 0.0 (interpolating) if no weights are supplied.

然而,经过大量测试,我还没能让它工作(平滑是非零的)。“拟合”通常看起来像一个任意的三次多项式。我处理的数据集应该是一个高次多项式,当合适的时候。仅仅通过修改平滑条件,我发现s=1E-9可以很好地平衡接近度和平滑度(我对数据使用权重)。在

有人知道发生了什么事吗?在

我使用三次样条曲线来代替其他插值方法是有原因的,但是我想知道我是否应该去别处看看。。。在


Tags: ofthe数据方法inifscipysqrt