Processing math: 100%
SciPy

This is documentation for an old release of SciPy (version 0.17.1). Read this page in the documentation of the latest stable release (version 1.15.1).

scipy.interpolate.UnivariateSpline.integral

UnivariateSpline.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 : float

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

Examples

>>>
>>> from scipy.interpolate import UnivariateSpline
>>> x = np.linspace(0, 3, 11)
>>> y = x**2
>>> spl = UnivariateSpline(x, y)
>>> spl.integral(0, 3)
9.0

which agrees with x2dx=x3/3 between the limits of 0 and 3.

A caveat is that this routine assumes the spline to be zero outside of the data limits:

>>>
>>> spl.integral(-1, 4)
9.0
>>> spl.integral(-1, 0)
0.0