# [SciPy-User] calculate definite integral of sampled data

Charles R Harris charlesr.harris@gmail....
Wed Aug 10 20:26:32 CDT 2011

```On Tue, Aug 9, 2011 at 11:59 PM, Manuel Graune <contact@graune.org> wrote:

> Hi everyone,
>
> to calculate the definite integral of a function or an array of sampled
> data scipy provides (among others) the quad and trapz functions.
> So it is possible to compute e. g. the definite integral of cos(t) over
> some interval by doing
>
>
> or
>
> definite_integral= scipy.integrate.trapz(some_array).
>
> Now, if I want to plot cos(t) and  the integral of cos(t) from 0 to t in
> a graph, the necessary array can be calculated by:
>
> @numpy.vectorize
> def intfunc(fnc,upper_limit):
>
>    definite_inegral= intfunc(cos,t)
>
> which seems (whithout knowing the actual code) a bit wasteful and slow
> but is relatively concise.
>
> Now for my question: scipy provides e. g. the trapz-function to
> calculate definite integral of a complete array of sampled data.
> However, I have no idea how to get achieve the same as above for
> sampled data (apart from manually iterating in a for-loop). Is there
> a function somewhere which delivers an array of the definite integrals
> for each of the data-points in an array?
>
>
> Regards,
>
> Manuel
>
>
How many data points do you have?

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20110810/4046c85a/attachment-0001.html
```