scipy.interpolate.lagrange

拉格朗日插值法是scipy库中常用的插值方法。

官网定义如下:

scipy.interpolate.lagrange(x, w)[source]
Return a Lagrange interpolating polynomial.

Given two 1-D arrays x and w, returns the Lagrange interpolating polynomial through the points (x, w).

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.

Parameters:	
x : array_like
x represents the x-coordinates of a set of datapoints.
w : array_like
w represents the y-coordinates of a set of datapoints, i.e. f(x).
Returns:	
lagrange : numpy.poly1d instance
The Lagrange interpolating polynomial.
其参数为两个一维数组,分别代表坐标的x值和y值,输出是多项式。可以直接用了计算插值。

例如:

x=[100,200,300,400]

y=[10,20,30,40]

f=lagrange(x,y)

求在500处的插值f(500)得到49.999999999999837,符号我们的数据

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.
这方法不是很稳定,所有输入的数据点最好不要超过20个

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值