python的scipy实现插值的示例代码

作者:your_answer 时间:2022-11-22 15:30:53 

插值对于一些时间序列的问题可能比较有用。

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()

python的scipy实现插值的示例代码

官网上有更详细的参数使用:https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.interpolate.interp1d.html

来源:https://blog.csdn.net/your_answer/article/details/79190900

标签:python,scipy,插值
0
投稿

猜你喜欢

  • Javascript将数值转换为金额格式(分隔千分位和自动增加小数点)

    2023-08-18 10:31:11
  • MySQL使用profile查询性能的操作教程

    2024-01-19 10:22:22
  • Oracle 数据库启动过程的三阶段、停库四种模式详解

    2024-01-16 04:05:25
  • python中requests和https使用简单示例

    2021-03-16 16:14:35
  • sql语句之数据操作介绍

    2024-01-22 18:09:39
  • Python 中创建 PostgreSQL 数据库连接池

    2024-01-19 22:33:37
  • Python的CGIHTTPServer交互实现详解

    2021-04-19 08:39:09
  • Win10安装MySQL5.7.18winX64 启动服务器失败并且没有错误提示

    2024-01-27 04:59:14
  • Python headers请求头如何实现快速添加

    2023-04-11 15:24:26
  • Python中with上下文管理协议的作用及用法

    2022-09-27 16:05:24
  • 举例讲解Python程序与系统shell交互的方式

    2021-10-29 14:43:17
  • 识别操作系统是不是vista的js代码

    2013-10-20 19:08:25
  • Python中的startswith和endswith函数使用实例

    2022-06-19 00:47:55
  • 利用python Selenium实现自动登陆京东签到领金币功能

    2021-11-09 12:00:33
  • 如何过滤中国站长站(chianz)文章干扰码

    2008-01-04 20:14:00
  • MySQL普通表如何转换成分区表

    2024-01-15 00:30:43
  • Python实现获取本地及远程图片大小的方法示例

    2022-10-21 19:10:04
  • Python批量生成幻影坦克图片实例代码

    2021-04-17 03:16:17
  • ASP生成静态页面的方法

    2010-05-27 12:13:00
  • Linux+php+apache+oracle环境搭建之CentOS下安装Oracle数据库

    2023-10-08 01:02:56
  • asp之家 网络编程 m.aspxhome.com