python 样条曲线拟合_在scipy python中使用UnivariateSpline拟合数据

有一些问题.

第一个问题是x值的顺序.从scipy.interpolate.UnivariateSpline的文档我们发现

x : (N,) array_like

1-D array of independent input data. MUST BE INCREASING.

压力增加了我.对于您给出的数据,x的顺序相反.

要调试它,使用“普通”样条曲线来确保一切都有意义是很有用的.

第二个问题,以及与您的问题更直接相关的问题,与s参数有关.它有什么作用?再次从我们找到的文档

s : float or None, optional

Positive smoothing factor used to choose the number of knots. Number

of knots will be increased until the smoothing condition is satisfied:

sum((w[i]*(y[i]-s(x[i])))**2,axis=0) <= s

If None (default), s=len(w) which should be a good value if 1/w[i] is

an estimate of the standard deviation of y[i]. If 0, spline will

interpolate through all data points.

因此,在最小二乘意义上,s确定插值曲线必须与数据点的接近程度.如果我们将值设置得非常大,那么样条曲线不需要靠近数据点.

作为一个完整的例子考虑以下内容

import scipy.interpolate as inter

import numpy as np

import pylab as plt

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值