MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Creating a Moving Average Function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg51652] Re: Creating a Moving Average Function
  • From: p-valko at tamu.edu (Peter Valko)
  • Date: Wed, 27 Oct 2004 23:43:25 -0400 (EDT)
  • References: <clnemu$obb$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Try out the ListConvolve function first. For instance the moving
average with weights 1/6, 2/3, 1/6 would work like this:

theSeries={a1, a2, a3, a4, a5, a6};
ListConvolve[{1/6, 4/6, 1/6}, theSeries, {2, 2}, 0] // TableForm


If you like what you get, you can modify the weights and can control
what is happening at the ends by changing the part:      {2, 2}, 0

I hope this helps.
Peter

Gregory Lypny <gregory.lypny at videotron.ca> wrote in message news:<clnemu$obb$1 at smc.vnet.net>...
> Hello Everyone,
> 
> I'd like to create some custom moving average functions that retain the 
> same length as the original series by padding the lost observations 
> with zeros.  I can get the moving average part of the function to work 
> but not the padding part.
> 
> This part without padding works:
> 
> MA[theSeries_, theWindowSize_] = MovingAverage[theSeries,
>      theWindowSize];
> 
> But adding the padding causes it to fail:
> 
> MA[theSeries_, theWindowSize_] = PadLeft[MovingAverage[theSeries,
>      theWindowSize], 1000];
> 
> Any suggestions would be most appreciated.
> 
> 	Greg


  • Prev by Date: Re: Help with a calculation
  • Next by Date: Re: Another bizarre phenomenon
  • Previous by thread: Re: Creating a Moving Average Function
  • Next by thread: Re: Creating a Moving Average Function