<< Chapter < Page Chapter >> Page >
This module is part of the collection, A First Course in Electrical and Computer Engineering . The LaTeX source files for this collection were created using an optical character recognition technology, and because of this process there may be more errors than usual. Please contact us if you discover any errors.

The simplest numerical filter is the simple averaging filter. This filter is defined by the equation

x = 1 N n = 1 N u n .

The filter output x is the average of the N filter inputs u 1 , u 2 , ... , u N . These inputs may be real or complex numbers, and x may be real or complex. This simple averaging filter is illustrated in Figure 1 .

A box diagram that consist several expressions, arrows and a rectangle. The image starts on the left with the expression u_1,u_2,...u_n. Then an arrow extends to the right and ends at a rectagle box containing the expression 1/N sum_(n=1)^(N) U_n. On the right side of the box a line extends to the right and ends at the expression x. A box diagram that consist several expressions, arrows and a rectangle. The image starts on the left with the expression u_1,u_2,...u_n. Then an arrow extends to the right and ends at a rectagle box containing the expression 1/N sum_(n=1)^(N) U_n. On the right side of the box a line extends to the right and ends at the expression x.
A Simple Averaging Filter

If the averaging filter is excited by the constant sequence u 1 = u 2 = = u N = u , then the output is

x = 1 N n = 1 N u = u .

The output is, truly, the average of the inputs. Now suppose the filter is excited by the linearly increasing sequence

u n = n , n = 1 , 2 , ... , N .

This sequence is plotted in Figure 2 . How do we sum such a sequence in order to produce the average x ? For N even, the average may be written as

x = 1 N ( x 1 + x N ) + 1 N ( x 2 + x N - 1 ) + + 1 N ( x N / 2 + x ( N / 2 ) + 1 ) .

Each pair-sum in parentheses equals N + 1 , and there are N 2 such pair-sums, so the average is

x = 1 N N 2 ( N + 1 ) = N + 1 2 .

This is certainly a reasonable answer for the average of a linearly increasing sequence. See Figure 2 .

This Cartesian graph contains several dots in a line. The line starts at the origin and rises with a positive slope. To the right of the line is the expression U_n versus N. Along the left side of the y axis there are two vertical dashes labeled 1 and two and then above these ticks there are three consecutive dots with the expression (N+1)/2 directly above that. The x axis is labeled with dashes labeled 1-8. Below dash 8 is the expression (N) the x axis is labeled n. This Cartesian graph contains several dots in a line. The line starts at the origin and rises with a positive slope. To the right of the line is the expression U_n versus N. Along the left side of the y axis there are two vertical dashes labeled 1 and two and then above these ticks there are three consecutive dots with the expression (N+1)/2 directly above that. The x axis is labeled with dashes labeled 1-8. Below dash 8 is the expression (N) the x axis is labeled n.
Linearly Increasing Sequence

General Sum Formula. Suppose the input to the simple averaging filter is the polynomial sequence

u n = n k , n = 1 , 2 , ... , N

where k is a non-negative integer such as k = 0 , 1 , 2 , ... . The output of the filter is

x N ( k ) = 1 N n = 1 N n k .

We rewrite x as x N ( k ) to remind ourselves that we are averaging N numbers, each of which is n k . For example, when N = 8 and k = 2 ,

x 8 ( 2 ) = 1 8 n = 1 8 n 2 = 1 8 ( 1 + 4 + 9 + + 64 ) .

Rather than study the average x N ( k ) , we will study the sum N x N ( k ) and divide by N at the very end:

S N ( k ) = N x N ( k ) = n = 1 N n k .

The sum S N ( k ) may be rewritten as the sum

S N ( k ) = n = 1 N - 1 n k + N k = S N - 1 ( k ) + N k .

This result is very important because it tells us that the sum S N ( k ) , viewed as a function of N , obeys a recursion in which S N ( k ) is just the sum using one less input, namely, S N - 1 ( k ) , plus N k . Now, since polynomials are the most general functions that obey such recursions, we know that s N ( k ) must be a polynomial of order k + 1 in the variable N :

s N ( k ) = a 0 + a 1 N + a 2 N 2 + + a k + 1 N k + 1 .

Let's check to see that this polynomial really can obey the required recursion. First note that S N - 1 ( k ) is the following polynomial:

s N - 1 ( k ) = a 0 + a 1 ( N - 1 ) + + a k + 1 ( N - 1 ) k + 1 .

The term ( N - 1 ) k + 1 produces ( 0 k + 1 ) N k + 1 ( - 1 ) 0 + ( 1 k + 1 ) N k ( - 1 ) 1 + . (Remember the binomial expansion?) Therefore the difference between S N ( k ) and S N - 1 ( k ) is

S N ( k ) - S N - 1 ( k ) = c 0 + c 1 N + + c k N k .

This recursion is general enough to produce the difference N k provided we can solve for a 0 , a 1 , ... , a k + 1 to make c 0 = c 1 = = c k - 1 = 0 and c k = 1 . We know that S N ( k ) = 0 for N = 0 , so we know that a 0 = 0 , meaning that the polynomial for S N ( k ) can really be written as

S N ( k ) = a 1 N + a 2 N 2 + + a k + 1 N k + 1 .

In order to solve for the coefficients of this polynomial, we propose to write out our equationfor s N ( k ) as follows:

( N = 1 ) S 1 ( k ) = a 1 + + a k + 1 ( N = 2 ) S 2 ( k ) = 2 a 1 + + 2 k + 1 a k + 1 ( N = 3 ) s 3 ( k ) = 3 a 1 + + 3 k + 1 a k + 1 ( N = k ) S k ( k ) = k a 1 + + k k + 1 a k + 1 ( N = k + 1 ) S k + 1 ( k ) = ( k + 1 ) a 1 + + ( k + 1 ) k + 1 a k + 1 .

Using the linear algebra we learned earlier, we may write these equations as the matrix equation

l 1 ... 1 2 4 ... 2 k + 1 k k 2 ... k k + 1 ( k + 1 ) ( k + 1 ) 2 ... ( k + 1 ) k + 1 a 1 a 2 a k + 1 = s 1 ( k ) S 2 ( k ) S k + 1 ( k ) .

The terms on the right-hand side of the equal sign are “initial conditions” that tell us how the sum S N ( k ) begins for N = 1 , 2 , ... , k + 1 . These initial conditions must be computed directly. (For example, S 2 ( k ) = 1 k + 2 k . ) Then the linear system of ( k + 1 ) equations in ( k + 1 ) unknowns may be solved for a 1 , a 2 , ... , a k + 1 . The solution for S N k is then complete, and we may use it to solve for S N k for arbitrary N .

When k = 2 , we have the following equation for the coefficients a 1 , a 2 , and a 3 in the polynomial S N ( 2 ) = a 1 N + a 2 N 2 + a 3 N 3 :

1 1 1 2 4 8 3 9 27 a 1 a 2 a 3 = 1 2 1 2 + 2 2 1 2 + 2 2 + 3 2 = 1 5 14 ·

Exponential Sums. When the input to an averaging filter is the sequence

u n = a n , n = 0 , 1 , 2 , ... , N - 1 ,

we say that the input is exponential (or geometric). Typical sequences are illustrated in Figure 6.5 for a = 0 . 9 , a = 1 , and a = 1 . 1 . Don't let it throw you that we have changed the index to run from 0 to N - 1 rather than from 1 to N . This change is not fundamentally important, but it simplifies our study. The sum of the inputs is

S N = n = 0 N - 1 a n .
Exponential Sequences

How do we evaluate this sum? Well, we note that the sum a S N is

a S N = n = 0 N - 1 a n + 1 = k = 1 N a k = k = 0 N - 1 a k + a N - 1 = S N + a N - 1 .

Therefore, provided a 1 , the sum S N is

S N = 1 - a N 1 - a , a 1 .

This formula, discovered already in the chapter covering the functions e x and e j θ , works for a 1 . When a = 1 , then S N = N :

S N = 1 - a N 1 - a , a 1 N , a = 1 .

When | a | < 1 , then a N 0 for N , and we have the asymptotic formula

lim N S N = 1 1 - a , | a | < 1 .

Recursive Computation. Every sum of the form

S N = n = 0 N - 1 u n

obeys the recursion

S N = S N - 1 + u N - 1 .

This means that when summing numbers you may “use them and discard them.” That is, you do not need to read them, store them, and sum them.

You may read u 0 to form S 1 and discard u 0 ; add u 1 to S 1 and discard u 1 ; add u 2 to S 2 ; and continue.

The Recursion S n + 1 = S n + u n

This is very important for hardware and software implementations of running sums. You need only store the current sum, not the measurements that produced it. Two illustrations of the recursion S n + 1 = S n + u n are provided in Figure 4 . The diagram on the left is self-explanatory. The diagram on the right says that the sum S n is stored in a memory location, to be added to u n to produce S n + 1 , which is then stored back in the memory location to be added to u n + 1 , and so on.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, A first course in electrical and computer engineering. OpenStax CNX. Sep 14, 2009 Download for free at http://cnx.org/content/col10685/1.2
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'A first course in electrical and computer engineering' conversation and receive update notifications?

Ask