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.
Suppose we try to extend our method for computing finite moving averages to infinite moving averages of the form
x
n
=
∑
k
=
0
∞
w
k
u
n
-
k
=
w
0
u
n
+
w
1
u
n
-
1
+
⋯
+
w
1000
u
n
-
1000
+
⋯
x
n
=
∑
k
=
0
∞
w
k
u
n
-
k
=
w
0
u
n
+
w
1
u
n
-
1
+
⋯
+
w
1000
u
n
-
1000
+
⋯
(1)
In general, this moving average would require infinite memory for the weighting coefficients w0,w1,...w0,w1,... and for the inputs un,un-1,...un,un-1,.... Furthermore, the hardware for multiplying wkun-kwkun-k would have to be infinitely fast to compute the infinite moving average in finite time. All of this is clearly fanciful and implausible (not to mention impossible). But what if the weights take the exponential form
w
k
=
0
,
k
<
0
w
0
a
k
,
k
≥
0
?
w
k
=
0
,
k
<
0
w
0
a
k
,
k
≥
0
?
(2)
Does any simplification result? There is hope because the weighting sequence
obeys the recursion
w
k
=
0
,
k
<
0
w
0
,
k
=
0
a
w
k
-
1
k
≥
1
.
w
k
=
0
,
k
<
0
w
0
,
k
=
0
a
w
k
-
1
k
≥
1
.
(3)
This recursion may be rewritten as follows, for k≥1k≥1:
wk-awk-1=0,k≥1.wk-awk-1=0,k≥1.
(4)
Let's now manipulate the infinite moving average and use the recursion for the weights to see what happens. You must follow every step:
x
n
=
∑
k
=
0
∞
w
k
u
n
-
k
=
∑
k
=
1
∞
w
k
u
n
-
k
+
w
0
u
n
=
∑
k
=
1
∞
a
w
k
-
1
u
n
-
k
+
w
0
u
n
=
a
∑
m
=
0
∞
w
m
u
n
-
1
-
m
+
w
0
u
n
=
a
x
n
-
1
+
w
0
u
n
.
x
n
=
∑
k
=
0
∞
w
k
u
n
-
k
=
∑
k
=
1
∞
w
k
u
n
-
k
+
w
0
u
n
=
∑
k
=
1
∞
a
w
k
-
1
u
n
-
k
+
w
0
u
n
=
a
∑
m
=
0
∞
w
m
u
n
-
1
-
m
+
w
0
u
n
=
a
x
n
-
1
+
w
0
u
n
.
(5)
This result is fundamentally important because it says that the output of the
infinite exponential moving average may be computed by scaling the previous
output xn-1xn-1 by the constant a, scaling the new input
u
n
u
n
by
w
0
w
0
, and adding.
Only three memory locations must be allocated: one for
w
0
w
0
, one for
a
a, and
one for xn-1xn-1. Only two multiplies must be implemented: one for axn-1axn-1 and
one for w0unw0un. A diagram of the recursion is given in Figure 1. In this
recursion, the old value of the exponential moving average, xn-1xn-1, is scaled
by
a
a and added to w0unw0un to produce the new exponential moving average
x
n
x
n
.
This new value is stored in memory, where it becomes xn-1xn-1 in the next step
of the recursion, and so on.
Try to extend the recursion of the previous paragraphs to the
weighted average
x
n
=
∑
k
=
0
N
-
1
a
k
u
n
-
k
.
x
n
=
∑
k
=
0
N
-
1
a
k
u
n
-
k
.
(6)
What goes wrong?
Compute the output of the exponential moving average xn=xn=axn-1+w0unaxn-1+w0un when the input is
u
n
=
0
,
n
<
0
u
,
n
≥
0
.
u
n
=
0
,
n
<
0
u
,
n
≥
0
.
(7)
Plot your result versus
n
n.
Compute
w
0
w
0
in the exponential weighting sequence
w
n
=
0
,
n
<
0
a
n
w
0
,
n
≥
0
w
n
=
0
,
n
<
0
a
n
w
0
,
n
≥
0
(8)
to make the weighting sequence a valid window. (This is a special case of
Exercise 3 from Filtering: Moving Averages.) Assume -1<a<1-1<a<1
"Reviewer's Comments: 'I recommend this book as a "required primary textbook." This text attempts to lower the barriers for students that take courses such as Principles of Electrical Engineering, […]"