xrscipy.integrate.simpson

xrscipy.integrate.simpson(obj, coord, even='avg')

Integrate y(x) using samples along the given coordinate and the composite

Simpson’s rule. If x is None, spacing of dx is assumed.

Parameters:
  • obj (xarray object) – Array to be integrated.

  • coord (string) – The coordinate along which to integrate.

Returns:

The estimated integral computed with the composite Simpson’s rule.

Return type:

float

See also

quad

adaptive quadrature using QUADPACK

fixed_quad

fixed-order Gaussian quadrature

dblquad

double integrals

tplquad

triple integrals

romb

integrators for sampled data

cumulative_trapezoid

cumulative integration for sampled data

cumulative_simpson

cumulative integration using Simpson’s 1/3 rule

scipy.integrate.simpson

scipy.integrate.simpson : Original scipy implementation

Notes

For an odd number of samples that are equally spaced the result is exact if the function is a polynomial of order 3 or less. If the samples are not equally spaced, then the result is exact only if the function is a polynomial of order 2 or less.

References

Examples

>>> from scipy import integrate
>>> import numpy as np
>>> x = np.arange(0, 10)
>>> y = np.arange(0, 10)

Examples

>>> integrate.simpson(y, x=x)
40.5

Examples

>>> y = np.power(x, 3)
>>> integrate.simpson(y, x=x)
1640.5

Examples

>>> integrate.quad(lambda x: x**3, 0, 9)[0]
1640.25