comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: smooth function and rounding error
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: smooth function and rounding error [message #69197 is a reply to message #69193] Fri, 18 December 2009 07:02 Go to previous messageGo to previous message
simona bellavista is currently offline  simona bellavista
Messages: 56
Registered: December 2009
Member
thanks Lorenzo, I missed that

>    in the Help of the smooth function it is said that "If a Width
> value is even, then Width+1 will be used instead."

anyway it looks even worse, that is unexpected to me.

I tried those routines for width=[10,100,100]; I see the relative
error gets bigger as the width gets smaller.
I include a subset of my data
0.11032583 0.094536981 0.075814606 0.056046214
0.037181503 0.021005635 0.0089338077 0.0018573446
6.1061458e-05
0.0032205319 0.010475696 0.020567541 0.032017375
0.043320873 0.053128306 0.060387275 0.064433200
0.065024946
0.062328237 0.056852040

I tried the following on the above data:

width=4
smoothed=SMOOTH(x,width)
smoothed_eq=smooth_equivalent(x,width)
diff=abs(smoothed-smoothed_eq)/double(smoothed)

and I get a diff ~0.5

I also found an old post
http://groups.google.it/group/comp.lang.idl-pvwave/browse_th read/thread/cfc1b4e88de957a1/e695c8d11af5446c?hl=it&lnk= gst&q=smooth#e695c8d11af5446c
where they talk about roundoff error in smooth, but it was 12 years
ago!

recap of implementation:

function smooth_equivalent, A, width
n=n_elements(A)
y=DBLARR(n)
y=A
width=width+1
for i=(width)/2,n-(width)/2-1,1 do begin
y[i]=total(A[i-width/2:i+width/2-1])/double(width) ; or double
(width+1)
endfor
RETURN, y
end

cheers,
simona
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: array index summations
Next Topic: ROI points don't seem to get stored properly

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 20:12:07 PDT 2025

Total time taken to generate the page: 0.88578 seconds