Skip to main content

Module sampled

Module sampled 

Source
Expand description

Integration of sampled data, following scipy.integrate: the composite trapezoid and Simpson rules for equally or unequally spaced samples, Romberg integration of 2ᵏ + 1 equally spaced samples, and the cumulative trapezoid and Simpson integrals.

See the book entry Integrating sampled data.

Enums§

Spacing
The sample positions: explicit abscissae, or a constant spacing.

Functions§

cumulative_simpson
The running Simpson integral (SciPy’s cumulative_simpson): each interval is integrated by the parabola through it and a neighbour (the next interval’s for the first of each pair, the previous one’s for the second), so every partial integral is exact for quadratics.
cumulative_trapezoid
The running trapezoid integral: element i integrates over the first i + 1 samples (SciPy’s cumulative_trapezoid). With initial, that value is prepended and added, so the result has the length of y; otherwise it is one shorter.
romb
Romberg integration of 2ᵏ + 1 equally spaced samples (SciPy’s romb): trapezoid sums on the nested grids of spacing h, 2h, 4h, …, combined by Richardson extrapolation R(i, j) = R(i, j−1) + (R(i, j−1) − R(i−1, j−1)) / (4ʲ − 1).
simpson
Simpson’s rule on pairs of intervals, (h₀ + h₁)/6 [(2 − h₁/h₀) y₀ + (h₀ + h₁)²/(h₀h₁) y₁ + (2 − h₀/h₁) y₂], the integral of the parabola through three samples (SciPy’s simpson). With an even number of samples, the last interval is integrated by the parabola through the last three samples (Cartwright’s correction), which keeps it exact for quadratics (but not cubics).
trapezoid
The composite trapezoid rule Σ (yᵢ + yᵢ₊₁) hᵢ / 2 (SciPy’s trapezoid).