小编Big*_*ief的帖子

scipy.interpolate.UnivariateSpline无论参数如何都不平滑

我无法获得scipy.interpolate.UnivariateSpline在插值时使用任何平滑.根据功能的页面以及之前的一些帖子,我相信它应该提供s参数的平滑.

这是我的代码:

# Imports
import scipy
import pylab

# Set up and plot actual data
x = [0, 5024.2059124920379, 7933.1645067836089, 7990.4664106277542, 9879.9717114947653, 13738.60563208926, 15113.277958924193]
y = [0.0, 3072.5653360000988, 5477.2689107965398, 5851.6866463790966, 6056.3852496014106, 7895.2332350173638, 9154.2956175610598]
pylab.plot(x, y, "o", label="Actual")

# Plot estimates using splines with a range of degrees
for k in range(1, 4):
    mySpline = scipy.interpolate.UnivariateSpline(x=x, y=y, k=k, s=2)
    xi = range(0, 15100, 20)
    yi = mySpline(xi)
    pylab.plot(xi, yi, label="Predicted k=%d" % k) …
Run Code Online (Sandbox Code Playgroud)

python splines scipy

3
推荐指数
2
解决办法
7094
查看次数

标签 统计

python ×1

scipy ×1

splines ×1