I think you may use scipy.integrate.simps a little incorrectly. The area returned by scipy.integrate.simps
is the total area under y
(the first parameter has passed). The second parameter is optional and represents sample values ββfor the x axis (actual x values ββfor each of the y values). i.e:
>>> import numpy as np >>> import scipy >>> a=np.array([1,1,1,1,1]) >>> scipy.integrate.simps(a) 4.0 >>> scipy.integrate.simps(a,np.array([0,10,20,30,40])) 40.0
I think you want to return the areas under the same curve between different limits? To do this, you pass the part of the curve that you want, for example:
>>> a=np.array([0,1,1,1,1,10,10,10,10,0]) >>> scipy.integrate.simps(a) 44.916666666666671 >>> scipy.integrate.simps(a[:5]) 3.6666666666666665 >>> scipy.integrate.simps(a[5:]) 36.666666666666664
source share