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!