I am trying to port from labview to python.
In labview there is a function "Integral x(t) VI" that takes a set of samples as input, performs a discrete integration of the samples and returns a list of values (the areas under the curve) according to Simpsons rule.
I tried to find an equivalent function in scipy, e.g. scipy.integrate.simps, but those functions return the summed integral across the set of samples, as a float.
How do I get the list of integrated values as opposed to the sum of the integrated values?
Am I just looking at the problem the wrong way around?
There is only one method in SciPy that does cumulative integration which is
scipy.integrate.cumtrapz()
which does what you want as long as you don't specifically need to use the Simpson rule or another method. For that, you can as suggested always write the loop on your own.I think you may be using scipy.integrate.simps slightly incorrectly. The area returned by
scipy.integrate.simps
is the total area undery
(the first parameter passed). The second parameter is optional, and are sample values for the x-axis (the actual x values for each of the y values). ie:I think you want to return the areas under the same curve between different limits? To do that you pass the part of the curve you want, like this: