[SciPy-user] splrep/splev versus interp1d
Johann Rohwer
jr at sun.ac.za
Wed May 21 04:24:42 EDT 2008
Hi,
What is the difference (in terms of the underlying algorithms) between
splines generated by sp.interpolate.interp1d and sp.interpolate.splrep/splev?
As an example, when I do a simple spline interpolation of a sparsely sampled
sin function, the two methods give me close but not identical results
(especially close to the bounds of the x data the interpolated values differ).
Code:
import scipy as sp
sp.pkgload('interpolate')
x=sp.linspace(0,10,11)
y=sp.sin(x)
x2=sp.linspace(0,10,201)
tck=sp.interpolate.splrep(x,y,k=3)
y2=sp.interpolate.splev(x2,tck)
f=sp.interpolate.interp1d(x,y,kind=3)
y3=f(x2)
y2 and y3 differ!
Regards
Johann
More information about the SciPy-User
mailing list