Re: replace integration by summation [message #84905 is a reply to message #84904] |
Tue, 18 June 2013 03:56   |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
On Tuesday, June 18, 2013 12:36:02 PM UTC+2, fd_...@mail.com wrote:
> Hi,
>
> I've been trying to replece the INT_TABULATED by total but the answer is very different and I don't see why.
>
>
>
> integration: A2= INT_TABULATED(t[0:i], A1[0:i])
>
>
>
> summation: A2 = (t[1]-t[0])*total(A1,/cumulative)
>
>
>
> I haven't been able to find out what is going wrong because these two commands seems similar to me and I didn't expect to get so wrong results. Can anyone help?
>
>
>
> With Thanks
>
> Maria
Well, I would suppose that the two types of integration methods are very different in how they integrate. In one case the so-called method of the rectangle rule (summation of array elements with /cumulative) will give very different results from int_tabulated specially when the data is very noisy and you're not sampling enough...
So, I would guess that the problem are the number of points you are using are not enough to describe the noise.
Try playing around with this:
x = (findgen(1001)/1000.0)*!pi
y = sin(x)*(RANDOMU(S,1001)*0.5)
print, (x[1]-x[0])*(total(y,/cumulative))[-1], INT_TABULATED(x,y)
the less points you use and the higher the noise, the more the results will differ (not tested, it's a guess...)
Cheers,
Helder
|
|
|