SoFunction
Updated on 2024-11-18

Interpolation in python scipy-interp implementation code

The specific code is shown below:

import numpy as np
from matplotlib import pyplot as plt
from  import interp1d
x=(0,10*,num=20)
y=(x)
f1=interp1d(x,y,kind='linear')#Linear interpolation
f2=interp1d(x,y,kind='cubic')# Cubic spline interpolation
x_pred=(0,10*,num=1000)
y1=f1(x_pred)
y2=f2(x_pred)
()
(x_pred,y1,'r',label='linear')
(x,f1(x),'b--','origin')
()
()
()
(x_pred,y2,'b--',label='cubic')
()
() 


这里写图片描述
这里写图片描述

summarize

The above is a small introduction to interpolation in python scipy-interp implementation code, I hope to help you, if you have any questions please leave me a message, I will promptly reply to you. I would also like to thank you very much for your support of my website!