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.
Interpolate a 1-D function. x and y are arrays of values used to approximate some function f: y = f(x) . This class returns a function whose call method uses interpolation to find the value of new points. Parameters x(N,) array_like. A 1-D array of real values.
The interp1d class in the scipy. interpolate is a convenient method to create a function based on fixed data points, which can be evaluated anywhere within the domain defined by the given data using linear interpolation. By using the above data, let us create a interpolate function and draw a new interpolated graph.
Interpolation is a technique of constructing data points between given data points. The scipy. interpolate is a module in Python SciPy consisting of classes, spline functions, and univariate and multivariate interpolation classes. Interpolation is done in many ways some of them are : 1-D Interpolation.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With