Integrate along the given axis using the composite trapezoidal rule.
Parameters: |
|
---|---|
Returns: | Definite integral as approximated by trapezoidal rule. |
Notes
Trapezoidal rule: y-axis locations of points will be taken from y array, by default x-axis distances between points will be 1.0, alternatively they can be provided with x array or with dx scalar.
References
Wikipedia page: http://en.wikipedia.org/wiki/Trapezoidal_rule
Examples
>>> trapz([1,2,3])
4.0
>>> trapz([1,2,3], x=[4,6,8])
8.0
>>> trapz([1,2,3], dx=2)
8.0
>>> a = arange(6).reshape(2, 3)
>>> a
array([[0, 1, 2]
[3, 4, 5]])
>>> trapz(a, axis=0)
array([1.5, 2.5, 3.5])
>>> trapz(a, axis=1)
array([2.0, 8.0])