I have two tabulated data arrays, x and y, and I don\'t know the function that generated the data. I want to be able to evaluate the integral of the line produced by the dat
Scipy has some nice tools to perform numerical integration.
For example, you can use scipy.integrate.simps to perform simpson's Rule, and you can pass it the following:
scipy.integrate.simps(y, x=None, dx=1, axis=-1, even='avg')
Parameters :
y : array_like Array to be integrated.x : array_like, optional If given, the points at which y is sampled.
dx : int, optional Spacing of integration points along axis of y. Only used when x is None. Default is 1.
axis : int, optional Axis along which to integrate. Default is the last axis.
even : {‘avg’, ‘first’, ‘str’}, optional
‘avg’ : Average two results:1) use the first N-2 intervals with a trapezoidal rule on the last interval and 2) use the last N-2 intervals with a trapezoidal rule on the first interval.
‘first’ : Use Simpson’s rule for the first N-2 intervals with a trapezoidal rule on the last interval.
‘last’ : Use Simpson’s rule for the last N-2 intervals with a trapezoidal rule on the first interval.
So you can use your two arrays to do numerical integration.