微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

scipy.interpolate.splrep 函数位于数据点之上

如何解决scipy.interpolate.splrep 函数位于数据点之上

我正在尝试为我的数据创建一个拟合,以便我可以从拟合中随机抽取 x 点并使用 scipy.splev 计算相应的 y 点

我的代码很简单。

> fit_spline = splrep(x,y,k=1) 
> 
> plt.plot(x,'.','r')
> 
> plt.plot(fit_spline[0],fit_spline[1]) 
> 
> plt.show()

其中 x 和 y 是红点的坐标。

我使用 k=1 是因为它最适合点。然而,样条始终向上和向左移动数据点,我不知道如何解决这个问题。

This is another example. The blue line is the interpolation from splrep and the red points are the data points

The blue line is the interpolation from splrep and the red points are the data points

解决方法

您的示例代码似乎缺少 splev 步骤,如 splev(x,fit_spline)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。