11.5. EXPONENTIAL AVERAGING
There is a kind of timedomain averaging used in
some power measurement equipment—it's called exponential
averaging[8–11].
This technique provides noise reduction by multiplying an input
sample by a constant and adding that product to the constant's ones
complement multiplied by the most recent averager output. Sounds
complicated in words, but the equation for the exponential averager
is the simple expression
where y(n) is the current averager output
sample, y(n–1) is the previous averager
output sample, and a is the weighting factor constant. The process
described by Eq. (1122)
is implemented as shown in Figure 1113. The advantage of exponential
averaging is that only one storage register is needed to hold the
value y(n–1) while waiting for the next
input data sample x(n).
Figure 1113. Exponential averager.
The exponential averager's name stems from its
timedomain impulse response. Let's assume that the input to the
averager is a long string of zeros and we apply a single sample of
value 1 at time t = 0. Then the
input returns again to a string of zerovalued samples. Now, if the
weighting factor is a = 0.4, the
averager's output is shown as the curve in Figure 1114. When t = 0, the input sample is multiplied by
a, so the output is 0.4. On the next
clock cycle, the input is zero, and the old value of 0.4 is
multiplied by (1 – 0.4), or 0.6, to provide an output of 0.24.
On the following clock cycle, the input is zero, and the old value
of 0.24 is multiplied by 0.6 to provide an output of 0.144. This
continues with the averager's output, or impulse response, falling
off exponentially because of successive multiplications by 0.6.
Figure 1114. Exponential averager
impulse response with a = 0.4.
A useful feature of the exponential averager is
its capability to vary the amount of noise reduction by changing
the value of the a weighting factor. If
a equals one, input samples are not
attenuated, past averager outputs are ignored, and no averaging
takes place. In this case, the averager output responds immediately
to changes at the input. As a is
decreased in value, input samples are attenuated, and past averager
outputs begin to affect the present output. These past values
represent an exponentially weighted sum of recent inputs, and that
summation tends to smooth out noisy signals. The smaller a gets, the more noise reduction is realized.
However, with smaller values for a, the
slower the averager is in responding to changes in the input. We
can demonstrate this behavior by looking at the exponential
averager's timedomain step response for various values of a as shown in Figure 1115.^{[]}
^{[]} The step
response is the averager's output when a string of all zeros
followed by a string of all ones is applied to the input.
Figure 1115. Exponential averager
output vs. a when a step input is
applied at time t = 0.
So we have a tradeoff. The more the noise
reduction, the more sluggish the averager will be in responding to
changes at the input. We can see in Figure 1115 that, as a gets smaller, affording better noise
reduction, the averager's output takes longer to respond and
stabilize. Some test instrumentation manufacturers use a clever
scheme to resolve this noise reduction versus response time
tradeoff. They use a large value for a
at the beginning of a measurement so that the averager's output
responds immediately with a nonzero value. Then, as the measurement
proceeds, the value of a is decreased to
reduce the noise fluctuations at the input.
The exponential averager's noise variance
reduction as a function of the weighting factor a has been shown to be[9,10]
Equation 1123
Thus, the exponential averager's noisepower
reduction in dB is given by
Equation 1124
Equation
(1124) is plotted in Figure 1116 to illustrate the tradeoff
between noise reduction and averager response times.
Figure 1116. Exponential averager
noisepower reduction as a function of the weighting factor a.
To demonstrate the exponential averager's
noisepower reduction capabilities, Figure 1117 shows the averager's output with
a cosine wave plus noise as an input. The weighting factor a starts out with a value of 1.0 and decreases
linearly to a final value of 0.1 at the 180th data input sample.
Notice that the noise is reduced as a
decreases. However, the cosine wave's peak amplitude also decreases
due to the smaller a value.
Figure 1117. Exponential averager
output noise reduction as a
decreases.
The reader may recognize the implementation of
the exponential averager in Figure 1113 as a onetap infinite impulse
response (IIR) digital filter[12].
Indeed it is, and, as such, we can determine its frequency
response.
We do this by remembering the general expression
in Chapter
6 for the frequency response of an IIR filter, or Eq.
(628) repeated here as
Equation 1125
From Figure 618, we
modify Eq. (1125) to set
N = 0, and M = 1, so that
Equation 1126
Now with b(0) =
a and a(1) = 1 – a, our exponential averager's frequency
response is the complex expression
Equation 1126'
For now, we're interested only in the magnitude
response of our filter, so we can express it as
Equation 1127
Evaluating Eq. (1127) over the normalized angular range
of 0 w p (corresponding to a
frequency range of 0
f f_{s}/2 Hz),
the frequency magnitude responses of our exponential averaging
filter for various values of a are shown
in Figure 1118(a) using a
normalized decibel scale. Notice that, as a decreases, the exponential averager behaves
more and more like a lowpass filter.
Figure 1118. Exponential averager
frequency response vs. a: (a) normalized
magnitude response in dB; (b) phase response in degrees.
We can get some practice manipulating complex
numbers by deriving the expression for the phase of an exponential
averager. We know that the phase angle, as a function of frequency,
is the arctangent of the ratio of the imaginary part of H_{exp}(w) over the real part of H_{exp}(w), or
Equation 1127'
To find those real and imaginary parts, knowing
that H_{exp}(w) is itself a ratio, we determine what the
variables are in Eq.
(1126') corresponding to the form of Eq. (A20),
from Appendix A. Doing that, we
get
Substituting those variables in Eq. (A20)
yields
Equation 1128
Representing the denominator of this messy Eq. (1128) with the term
Den, we use Eq. (1127) to express the phase angle of
H_{exp}(w) as
Equation 1129
The very nonlinear phase of
ø_{exp}(w) from Eq. (1129) is calculated
over the normalized angular range of 0 w p, corresponding to a
frequency range of 0
f f_{s}/2 Hz,
and plotted in Figure
1118(b).
