python的scipy实现插值的示例代码
更新时间:2019年11月12日 16:26:19 作者:your_answer
这篇文章主要介绍了python的scipy实现插值的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
插值对于一些时间序列的问题可能比较有用。
Show the code directly:
import numpy as np from matplotlib import pyplot as plt from scipy.interpolate import interp1d x=np.linspace(0,10*np.pi,num=20) y=np.sin(x) f1=interp1d(x,y,kind='linear')#线性插值 f2=interp1d(x,y,kind='cubic')#三次样条插值 x_pred=np.linspace(0,10*np.pi,num=1000) y1=f1(x_pred) y2=f2(x_pred) plt.plot(x_pred,y1,'r',label='linear') plt.plot(x_pred,y2,'b--',label='cubic') plt.legend() plt.show()
官网上有更详细的参数使用:https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.interpolate.interp1d.html
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
相关文章
CentOS 7 安装python3.7.1的方法及注意事项
这篇文章主要介绍了CentOS 7 安装python3.7.1的方法,文中给大家提到了注意事项,需要的朋友可以参考下2018-11-11caffe binaryproto 与 npy相互转换的实例讲解
今天小编就为大家分享一篇caffe binaryproto 与 npy相互转换的实例讲解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2018-07-07
最新评论