cupyx.scipy.interpolate.InterpolatedUnivariateSpline#

class cupyx.scipy.interpolate.InterpolatedUnivariateSpline(x, y, w=None, bbox=[None, None], k=3, ext=0)[source]#

1-D interpolating spline for a given set of data points.

Fits a spline y = spl(x) of degree k to the provided x, y data. Spline function passes through all provided points. Equivalent to UnivariateSpline with s = 0.

Parameters:
  • x ((N,) array_like) – Input dimension of data points – must be strictly increasing

  • y ((N,) array_like) – input dimension of data points

  • w ((N,) array_like, optional) – Weights for spline fitting. Must be positive. If None (default), weights are all 1.

  • bbox ((2,) array_like, optional) – 2-sequence specifying the boundary of the approximation interval. If None (default), bbox=[x[0], x[-1]].

  • k (int, optional) – Degree of the smoothing spline. Default is k = 3, a cubic spline.

  • ext (int or str, optional) –

    Controls the extrapolation mode for elements not in the interval defined by the knot sequence.

    • if ext=0 or ‘extrapolate’, return the extrapolated value.

    • if ext=1 or ‘zeros’, return 0

    • if ext=2 or ‘raise’, raise a ValueError

    • if ext=3 of ‘const’, return the boundary value.

    The default value is 0.

Methods

__call__(x, nu=0, ext=None)[source]#

Evaluate spline (or its nu-th derivative) at positions x.

Parameters:
  • x (ndarray) – A 1-D array of points at which to return the value of the smoothed spline or its derivatives. Note: x can be unordered but the evaluation is more efficient if x is (partially) ordered.

  • nu (int) – The order of derivative of the spline to compute.

  • ext (int) –

    Controls the value returned for elements of x not in the interval defined by the knot sequence.

    • if ext=0 or ‘extrapolate’, return the extrapolated value.

    • if ext=1 or ‘zeros’, return 0

    • if ext=2 or ‘raise’, raise a ValueError

    • if ext=3 or ‘const’, return the boundary value.

    The default value is 0, passed from the initialization of UnivariateSpline.

antiderivative(n=1)[source]#

Construct a new spline representing the antiderivative of this spline.

Parameters:

n (int, optional) – Order of antiderivative to evaluate. Default: 1

Returns:

spline – Spline of order k2=k+n representing the antiderivative of this spline.

Return type:

UnivariateSpline

derivative(n=1)[source]#

Construct a new spline representing the derivative of this spline.

Parameters:

n (int, optional) – Order of derivative to evaluate. Default: 1

Returns:

spline – Spline of order k2=k-n representing the derivative of this spline.

Return type:

UnivariateSpline

derivatives(x)[source]#

Return all derivatives of the spline at the point x.

Parameters:

x (float) – The point to evaluate the derivatives at.

Returns:

der – Derivatives of the orders 0 to k.

Return type:

ndarray, shape(k+1,)

get_coeffs()[source]#

Return spline coefficients.

get_knots()[source]#

Return positions of interior knots of the spline.

Internally, the knot vector contains 2*k additional boundary knots.

get_residual()[source]#

Return weighted sum of squared residuals of the spline approx.

This is equivalent to:

sum((w[i] * (y[i]-spl(x[i])))**2, axis=0
integral(a, b)[source]#

Return definite integral of the spline between two given points.

Parameters:
  • a (float) – Lower limit of integration.

  • b (float) – Upper limit of integration.

Returns:

integral – The value of the definite integral of the spline between limits.

Return type:

float

set_smoothing_factor(s, t=None)[source]#

Continue spline computation with the given smoothing factor s and with the knots found at the last call.

This routine modifies the spline in place.

__eq__(value, /)#

Return self==value.

__ne__(value, /)#

Return self!=value.

__lt__(value, /)#

Return self<value.

__le__(value, /)#

Return self<=value.

__gt__(value, /)#

Return self>value.

__ge__(value, /)#

Return self>=value.