Re: Sky is falling, maybe? [message #68231 is a reply to message #68230] |
Thu, 08 October 2009 12:11   |
Foldy Lajos
Messages: 268 Registered: October 2001
|
Senior Member |
|
|
On Thu, 8 Oct 2009, Lasse Clausen wrote:
> I find the following odd but maybe the sky is just falling and one of
> you guys can explain why this happens. Try running
>
> power = randomu(1001, 150)
> power[77+lindgen(10)*3] = 1e+7
> help, where(~finite(power))
> plot, power, yrange=[.1, 10]
> loadct, 12
> oplot, smooth(power, 12, /nan), thick=3, color=20
> oplot, smooth(power, 12), thick=3, color=120
> end
>
> On my machine
>
> IDL> print, !version
> { x86_64 linux unix linux 7.0 Oct 25 2007 64 64}
>
> I see a distinct difference in the SMOOTH output after the very uppy-
> downy bit of the data. It seems the documentation should be changed
> from
>
> SMOOTH should never be called without the NAN keyword if the input
> array may possibly contain NaN values.
>
> to
>
> SMOOTH should never be called without the NAN. Period.
>
> Again, maybe I'm missing something but the SMOOTH function seems like
> a pretty straight forward piece of code - without ever having seen it,
> of course - that leaves very little room for error. But by the same
> token we all know that "Every program has at least one bug and can be
> shortened by at least one instruction - from which, by induction - it
> can be shown that every program can be reduced to one instruction that
> doesn't work".
>
> So long
> Lasse
>
Yes, the sky is falling, again :-) Try with 'power=double(power)' and the
difference will disappear (randomu and 1e7 are too far apart for float).
smooth(...) and smooth(..., /nan) use different algorithms. The previous
one uses a sliding window, while the other does not (the sliding window
would give all NaNs after the first NaN).
regards,
lajos
|
|
|