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

Home » Public Forums » archive » SMOOTH or TS_SMOOTH
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 or TS_SMOOTH [message #82179 is a reply to message #82100] Wed, 21 November 2012 06:28 Go to previous messageGo to previous message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
Le mercredi 21 novembre 2012 14:09:46 UTC+1, mark...@gmail.com a écrit :
> Typing code too quick....corrected version
>
>
>
> X = 50
>
> N = 3
>
> arrayData = dindgen(X)
>
> arrayBackwardMovingMean = dblarr(X)
>
> for i = 0, X - 1 do arrayBackwardMovingMean[i] = mean(arrayData[min([0, i - N] : i)])

A more "IDL" way (untested) might be :

pad = !Values.F_NAN + dindgen(N)
print, mean(reform([pad,reform(rebin([arrayData,pad],X+N,N),(X*N)*N )],X+N+1,N),DIM=2,/NAN)

or, more explicitely:

print,mean( $
reform( $
[pad,reform(rebin([arrayData,pad],X+N,N),(X*N)*N)] $ ;replicate and pad your array N times
,X+N+1,N), $ ;do the shift
DIM=2, $ ;do the average
/NAN) ;handle the bounds


alx.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Saving via ImageMagick with Coyote Routines fails II
Next Topic: PLOTS versus POLYLINE

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

Current Time: Wed Oct 08 18:04:51 PDT 2025

Total time taken to generate the page: 0.00191 seconds