MathGroup Archive 2006

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

Search the Archive

Re: Moving average / smoothing data

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64080] Re: Moving average / smoothing data
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Tue, 31 Jan 2006 01:14:33 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

On 1/29/06 at 11:10 PM, lrebanks at netvigator.com (Lea Rebanks) wrote:

>Given the following function & subsequent plot.

>tt={1.5*Sin[x]+0.5*Sin[20*x],1.5*Sin[x]};
>pp=Plot[Evaluate[tt],{x,0,20}];

>I am trying to get the best smoothing / moving average function
>closest to the underlying 1.5*sin[x]

>Has anyone got any suggestions? Please show coding in reply so I
>can plot & see result.

>I have similar noise on exponential data, so hopefully the moving
>average you recommend will work on that too.

A moving average can easily be implemented using either ListConvolve or ListCorrelate.

First get a data sample, i.e.,

sample = Table[1.5*Sin[x] + 0.5*Sin[20*x], {x, 0, 20, 0.1}];

Next you will need a kernel to use with ListConvolve. A function to compute the needed kernel for a window size of n is:

ker[n_]:=Table[1/n, {n}]

Now the moving average can be computed as

smoothed = ListConvolve[ker[10], sample];

and the plot

ListPlot[smoothed, PlotJoined->True];

clearly shows the underlying 1.5 Sin[x] function.

However, using a moving average directly with exponential data may not be the best choice.  With a large window size, you are computing the average of a non linear function which will distort the appearance of the plot. The distortion can be minimized by using smaller window sizes at the cost of less reduction in the noise signal. It is not obvious to me a moving average will be effective at removing sinusoidal noise from exponential data.
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Moving average / smoothing data
  • Next by Date: Re: General--A Minor Annoyance
  • Previous by thread: Re: Moving average / smoothing data
  • Next by thread: Re: Moving average / smoothing data