Reputation: 3404
I'm trying to set the behavior at the boundaries for SciPy's interp1d
function, which according to the documentation should be possible:
Behavior at the boundary can be specified at instantiation time.
But I have not found any further information on this. The interp1d documentation does not mention it all.
So: How can I define the behavior?
Side-curiosity: What is the default boundary behavior it uses?
Edit: Examples (Assuming data points between x=0
and x=n
and cubic interpolation)
I know of at least three types of boundary behavior that I would like to be able to specify:
flat: I could demand the function to flat out, in other words derivations to be zero.
f'(0) = f'(n) = 0
f''(0) = f''(n) = 0
cyclic: Something among the lines of
f'(0) = f'(n)
f''(0) = f''(n)
Thus the beginning and end have same "slope".
manual: Or I could manually provide the values for the derivatives...
f'(0) = ...
f'(n) = ...
f''(0) = ...
f''(n) = ...
Although probably not for all four of them at the same time.
Upvotes: 6
Views: 5578
Reputation: 11201
I believe that sentence in the documentation is badly phrased, just ignore it.
The interp1d
function, at present, does not allow to specify the boundary behaviour,
interp1d
uses the spline constructor scipy.interpolate.splmake
with the default parameter kind='smoothest'
, so again no choice on the boundary behaviour there.On the other hand, you might want to have a look at scipy.interpolate.PiecewisePolynomial
which represents the curve with piecewise polynomials and has the ability to specify the derivatives (although for all knots and not only at the boundaries).
Upvotes: 3