[Numpy-discussion] confused about univaritespline

Pauli Virtanen pav at iki.fi
Tue Nov 20 14:17:13 EST 2012


20.11.2012 21:11, Neal Becker kirjoitti:
> import numpy as np
> import matplotlib.pyplot as plt
> 
> ibo = np.array ((12, 14, 16, 18, 20, 22, 24, 26, 28, 29, 29.8, 30.2))
> gain_deriv = np.array ((0, 0,  0,  0,   0, 0,  .2, .4, .5, .5, 0,    -2))
> 
> import scipy.interpolate
> s = scipy.interpolate.UnivariateSpline(ibo, gain_deriv, s=0.1)
> 
> xs = linspace(12, 31, 100)
> gain = np.vectorize (lambda x: s.integral (12, x)) (xs)
> 
> plot (xs, s(xs))
> plot (xs, gain)

>From fitpack/splint.f:

c           s(x) is considered to be identically zero outside
c           the interval (t(k+1),t(n-k)).

Not documented in the Python wrapper, though.

-- 
Pauli Virtanen




More information about the NumPy-Discussion mailing list