       Re: Re: Multiple application of LinearFilter

• To: mathgroup at smc.vnet.net
• Subject: [mg64858] Re: [mg64850] Re: Multiple application of LinearFilter
• From: "Lea Rebanks" <lrebanks at netvigator.com>
• Date: Mon, 6 Mar 2006 05:00:59 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Many thanks Bill.

Very interesting. I will try that, however I feel I may run into problems.

to you.

I have tried figuring out your cryptic email below with no success after
many tries.

Speak soon.

Best Regards - Lea Rebanks...

-----Original Message-----
To: mathgroup at smc.vnet.net
Subject: [mg64858] [mg64850] Re: Multiple application of LinearFilter

On 3/4/06 at 2:35 AM, lrebanks at netvigator.com (Lea Rebanks) wrote:

>I have been using LinearFilter on my data with great success &
>achieve better results the more times I pass my data through the
>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.

Yes. But rather than using LinearFilter, I think the built-in function
ListConvolve is more efficient and flexible. For your specific
application, ListConvolve differs from LinearFilter only in the order of
the arguments, i.e.,

In:=
LinearFilter[{a,b,c,d},{1/2,1/2}]==ListConvolve[{1/2,1/2},{a,b,c,d}]

Out=
True

Repeated passes with a given kernel are equivalent to a single pass with
a longer kernel. That is 3 passes with the kernel (1/2,1/2) give the
same result as a single pass with the kernel {1/8,3/8,3/8,1/8}

Here is three passes using ListConvolve and the kernel {1/2,1/2}

In:=
ListConvolve[{1/2, 1/2},
ListConvolve[{1/2, 1/2}, ListConvolve[{1/2, 1/2},
{a, b, c, d, e, f}]]]//Simplify

Out=
{(1/8)*(a + 3*b + 3*c + d), (1/8)*(b + 3*c + 3*d + e),
(1/8)*(c + 3*d + 3*e + f)}

and here is the result using a single pass

In:=
ListConvolve[{1/8, 3/8, 3/8, 1/8}, {a, b, c, d, e, f}]//Simplify

Out=
{(1/8)*(a + 3*b + 3*c + d), (1/8)*(b + 3*c + 3*d + e),
(1/8)*(c + 3*d + 3*e + f)}

As you can see the results are the same.

flexibility ListConvolve gives, For example, to get an output the same
length as the input you can do

In:=
ListConvolve[{1/2, 1/2},  {a, b, c}, {1, 1}]

Out=
{a/2 + c/2, a/2 + b/2, b/2 + c/2}

or if you wanted the equivalent of

you could do

ListConvolve[{1/2,1/2},{a,b,c},{1,1},0]
--
To reply via email subtract one hundred and four

```

• Prev by Date: Re: Multiple application of LinearFilter
• Next by Date: Re: General--Making the DisplayFormula style in ArticleModern look like Traditional
• Previous by thread: Re: Multiple application of LinearFilter
• Next by thread: Re: Re: Multiple application of LinearFilter