Numerical integration of a periodic function result in an increasing function

347 Views Asked by At

I have a sequence of a samples coming from sampled and processed periodic signals. I need to approximate the integral of these signals.

Using scipy.integrate.cumtrapz which applies the composite trapezoidal rule I obtained the integrated samples, but I have a problem. One of these integrated functions become a decreasing function, and I have no idea of what is going on... This is the simply code I used:

test_set_y_int = integrate.cumtrapz(test_set_y) 
y_int = integrate.cumtrapz(y)

The plot of the initial signals, the blue one is test_set_y, the red one is y : initial signals

The plot of the integrated signals, the blue one is test_set_y_int, the red one is y_int. integrated signals

Any suggestions about what is happening and what should I do?

1

There are 1 best solutions below

3
On

That's not surprising, as a simpler example may show more clearly: $f(x)=1+\cos x$ is periodic, and $\int^x_0f(x)\,dx=x+\sin x$ is increasing.