lisa.datautils.series_integrate#
- lisa.datautils.series_integrate(y, x=None, sign=None, method='rect', rect_step='post')[source]#
Compute the integral of y with respect to x.
- Returns:
A scalar \(\int_{x=A}^{x=B} y \, dx\), where x is either the index of y or another series.
- Parameters:
y (pandas.DataFrame) – Series with the data to integrate.
x (pandas.DataFrame or None) – Series with the x data. If
None
, the index of y will be used. Note that y and x are expected to have the same index.sign (str or None) –
Clip the data for the area in positive or negative regions. Can be any of:
+
: ignore negative data-
: ignore positive dataNone
: use all data
method – The method for area calculation. This can be any of the integration methods supported in
numpy
or rectrect_step (str) – The step behaviour for rect method
Rectangular Method
Step: Post
Consider the following time series data:
2 *----*----*----+ | | 1 | *----*----+ | 0 *----*----+ 0 1 2 3 4 5 6 7 import pandas as pd a = [0, 0, 2, 2, 2, 1, 1] s = pd.Series(a)
The area under the curve is:
\[\begin{split}\sum_{k=0}^{N-1} (x_{k+1} - {x_k}) \times f(x_k) \\ (2 \times 3) + (1 \times 2) = 8\end{split}\]Step: Pre
2 +----*----*----* | | 1 | +----*----*----+ | 0 *----* 0 1 2 3 4 5 6 7 import pandas as pd a = [0, 0, 2, 2, 2, 1, 1] s = pd.Series(a)
The area under the curve is:
\[\begin{split}\sum_{k=1}^{N} (x_k - x_{k-1}) \times f(x_k) \\ (2 \times 3) + (1 \times 3) = 9\end{split}\]