interpax.approx_df

interpax.approx_df(x: Array, f: Array, method: str = 'cubic', axis: int = -1, **kwargs)Source

Approximates first derivatives using cubic spline interpolation.

Parameters:
  • x (ndarray, shape(Nx,)) – coordinates of known function values (“knots”)

  • f (ndarray) – Known function values. Should have length Nx along axis=axis

  • method (str) –

    method of approximation

    • 'cubic': C1 cubic splines (aka local splines)

    • 'cubic2': C2 cubic splines. Can also pass kwarg bc_type, same as scipy.interpolate.CubicSpline

    • 'catmull-rom': C1 cubic centripetal “tension” splines

    • 'cardinal': C1 cubic general tension splines. If used, can also pass keyword parameter c in float[0,1] to specify tension

    • 'monotonic': C1 cubic splines that attempt to preserve monotonicity in the data, and will not introduce new extrema in the interpolated points

    • 'monotonic-0': same as 'monotonic' but with 0 first derivatives at both endpoints

    • 'akima': C1 cubic splines that appear smooth and natural

  • axis (int) – Axis along which f is varying.

Returns:

df (ndarray, shape(f.shape)) – First derivative of f with respect to x.