# [SciPy-user] question about splines

Darren Dale dd55 at cornell.edu
Sat Dec 3 23:07:50 CST 2005

I have a question about the interpolate.splrep and interpolate.splev
functions, which I am using to find the inflection point in some data.
I am testing these functions with a sine curve, just finding the spline
representations and then evaluating them:

from scipy import *

n=1000
xmin, xmax = 0,1
x = linspace(xmin,xmax,n)
ymin, ymax = 0, 2*pi
y = sin(linspace(ymin,ymax,n))

weights = ones(n)/0.00001 # 1/stdev for noisy data
derivative = 2
print interpolate.splev(x,interpolate.splrep(x,y,s=n,w=weights),derivative).max()

If I were using this tool correctly, the reported maximum would be
very close to 1 for any derivative. derivative=0 does yield a good
approximation. If derivative is not 0, the amplitude of the result can
be off by orders of magnitude. The amplitude of the derivative
curve is effected by the limits of x and y, which I don't understand.

I must have overlooked something, does anyone have a suggestion?

Thanks,
Darren