MathGroup Archive 2006

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

Search the Archive

Re: Multiple application of LinearFilter

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64840] Re: [mg64823] Multiple application of LinearFilter
  • From: Pratik Desai <pdesai1 at umbc.edu>
  • Date: Sun, 5 Mar 2006 03:19:00 -0500 (EST)
  • References: <200603040735.CAA15850@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Lea Rebanks wrote:

> 
>Hi All,
> 
>I have been using LinearFilter on my data with great success & achieve
>better results the more times I pass my data through the LinearFilter. (
>I have had to adjust data length to maintain correct indexing with
>PadLeft - but this is not my question here.)
> 
>Below is how I am applying the multiple LinearFilter.
> 
>EG
> 
>originaldata
> 
>Data1=LinearFilter[originaldata, {1/2,1/2}];
>Data2=LinearFilter[Data1, {1/2,1/2}];
>Data3=LinearFilter[Data2, {1/2,1/2}];
> 
> 
>My question is - Is there a shorter way of writing multiple passes of
>the above.
> 
>If there is a way, please show the code.
> 
>It would be great if I could simply adjust the number of passes from say
>three above to any number of passes to find optimum setting for data.
> 
>Many thanks for your attention.
> 
>Best Regards - Lea Rebanks...
> 
> 
>
>  
>
Hi Lea,

Maybe something like this
In[1]:=
Clear[data1,data2,data3,reps]
<<Statistics`DataSmoothing`
data1 = {7.,4.,5.,3.,8.,5.,2.,3.,6.,8.};
reps=Nest[LinearFilter[#,{1/2,1/2}]&,data1,3]
data2=LinearFilter[data1,{1/2,1/2}]
data3=LinearFilter[data2,{1/2,1/2}]
data4=LinearFilter[data3,{1/2,1/2}]
reps===data4

Out[4]=
{4.625,4.5,5.375,5.5,4.,3.25,4.625}

Out[5]=
{5.5,4.5,4.,5.5,6.5,3.5,2.5,4.5,7.}

Out[6]=
{5.,4.25,4.75,6.,5.,3.,3.5,5.75}

Out[7]=
{4.625,4.5,5.375,5.5,4.,3.25,4.625}

Out[8]=
True

If you have somekind of termination criteria you may even try NestWhile 
and NestWhileList


Hope this helps

Pratik


  • Prev by Date: Re: Trouble with tables
  • Next by Date: Re: Multiple application of LinearFilter
  • Previous by thread: Multiple application of LinearFilter
  • Next by thread: Re: Multiple application of LinearFilter