4 Smoothing and Windowing In this chapter we consider ways to improve discrete sequences, including the reduction of data contamination and the improvement of certain time and frequency properties. Smoothing and windowing are useful tools for signal waveform processing in both domains. SimpliÞcations with limited goals will be a desirable approach. The References in this chapter can be consulted for more advanced studies. Our suggested approaches are quite useful, where great sophistication is not required, for the processing of many commonly occurring discrete-signal waveforms. SMOOTHING Consider Fig. 4-1a and the rectangular discrete sequence W (i ) for (i ) from 0 to 63 with amplitude 1.0 and drawn in continuous form for visual clarity. The simple Mathcad Program shown creates this sequence. Observe that the rectangle is delayed at the beginning and terminated early (“pedestal” would be a good name). This sequence is a particular kind of simple win- dow that is useful in many situations because of the zero-value segments Discrete-Signal Analysis and Design, By William E. Sabin Copyright 2008 John Wiley & Sons, Inc. 61 62 DISCRETE-SIGNAL ANALYSIS AND DESIGN Y 1 (i) := .25 ⋅W (i − 1) + .5 ⋅W (i) + .25 ⋅W (i + 1) Y 2 (i) := .25 ⋅Y 1 (i − 1) + .5 ⋅Y 1 (i) + .25 ⋅Y 1 (i + 1) Y 3 (i) := .25 ⋅Y 2 (i − 1) + .5 ⋅Y 2 (i) + .25 ⋅Y 2 (i + 1) Y 8 (i) := .25 ⋅Y 7 (i − 1) + .5 ⋅Y 7 (i) + .25 ⋅Y 7 (i + 1) (a) no smoothing 3 smoothings 8 smoothings W(i) := 0 W(i) := 0 1 if i ≥ 8 1 + rnd(1) if i ≥ 8 0 if i > 56 0 if i > 56 i := 0,1 63 i := 0,1 63 (b) 3 smoothings 8 smoothings No smoothin g Rectangular Figure 4-1 Smoothing operation on a discrete signal waveform: (a) with- out added random noise; (b) with added random noise. at each end that are known as guardbands that greatly reduce spillover (aliasing, Chapter 3) into adjacent regions. Figure 4-1 then shows how, at each value of (i), the three-point smooth- ing sequence 0.25, 0.5, 0.25 is applied to the data points W (i −1), W (i), and W (i +1), respectively, to get Y 1 (i ). We then repeat the operation, using the Y 1 (i ) values to get the Y 2 (i ) values, then the Y 2 (i ) values to get the Y 3 (i ) values, and so on. We pause at Y 3 to view the intermedi- ate results, and see that the edges of the rectangle have been “softened” and the pattern is extended away from the boundaries of the rectangle. We then continue on to Y 8 , and the pattern becomes pretty well stabi- lized. In other words, where the Y values become small, the smoothing SMOOTHING AND WINDOWING 63 sequences produce less and less effect, so that further spreading becomes “negligible”. Observe also that the maximum amplitude of the smoothed sequence is essentially 1.0. The choice of smoothing sequence values with the sum [0.25 +0.5 +0.25] =1.0 is responsible for this result. In Fig. 4-1b some noise, the random number function rnd(1.0) with values from (0 to +1), has been added to the rectangular region as shown in the Mathcad program. After eight smoothing operations the noise has been greatly reduced and the maximum amplitude is nearly the 1.0 of the rectangle plus the average of the noise component, which is 0.5. The value of root-mean-square (RMS) noise and the ratio in dB of RMS noise to the highly smoothed signal within the rectangular region are matters of practical interest. The procedure is to: 1. Find the partially smoothed sequence Y 3 (i ) for example. 2. Find the more highly smoothed sequence Y 8 (i ) and use it as a reference. 3. At each point (i), Þnd the square of the difference between sequences Y 3 (i )andY 8 (i ). 4. Divide the result of step 3 by the square of the Y 8 (i )values. 5. Get the sum of the squares and divide the sum by the number of values in the rectangular region. 6. Find the positive square root of step 5 that produces an RMS noise voltage. 7. The result is a single estimate of the RMS signal in the partially smoothed sequence. Each repetition of steps 1 to 6 is an additional estimate that can be averaged with the others. The regions outside the rectangle are not included because the noise signal in this example is gated on only within the rectangle; however, the smoothing of rectangle-plus-noise spreads the rectangle itself almost as in Fig. 4-1a. All of this can be combined into a single equation for the noise ratio (NR) within the rectangle region in Fig 4-1b: NR dB = 10 log 1 49 56 i=8 Y 3 (i) − Y 8 (i) Y 8 (i) 2 dB (4-1) 64 DISCRETE-SIGNAL ANALYSIS AND DESIGN The result is the ratio, in dB, between a three-sweep and an eight-sweep record. Another sequence that was evaluated has seven values: [0.015625+ 0.09375 + 0.23438 +0.31250 +0.23438 +0.09375 + 0.015625] = 1.0. This sequence was found to give about the same results for Þ ve passes as the three-point sequence with eight passes. The spectrum plot in Fig. 4-2a compares the two methods. Mathcad Þnds the three-point method to be 0 5 10 15 20 25 30 −80 −70 −60 −50 −40 −30 −20 −10 0 3 points 7 points dB Frequency DC −70 −60 −50 −40 −30 −20 −10 0 dB (a) ( b ) 0 5 10 15 20 25 30 (A) (B) Frequency Figure 4-2 (a) Comparing a three-point sequence with a seven-point sequence in spectrum decibels. (b) Comparing the spectrum of the rectan- gular pulse of Fig. 4-1 before (A) and after (B) eight 3-point smoothings. (c) (1) Time domain of triangular waveform; (2) spectrum before (gray line) and after (black line) three-point smoothing of the spectrum. SMOOTHING AND WINDOWING 65 consistently better at the higher frequencies. Also, the smoothing of the sequences can be in the time domain (Fig. 4-1) or the frequency domain (Fig. 4-2). For further study of smoothing methods, see, for example, [Oppenheim and Schafer 1975] and [Jenkins and Watts 1968]. We see a potential problem in Fig. 4-1a. A smoothed record that exists from 0 to N −1 calls for a value of (i )intheÞrst step that is less than zero (in a negative-time region). The Þnal step calls for an (i ) value that is greater than N −1 (in a positive-time region). An excellent way to handle this is to use circular smoothing. When i =−1 is called for, use i =N −1, and when i =N is called for, use i =0. This keeps us within 0 5 10 15 20 25 30 0 0.25 0.5 0.75 1 n (1) 012345678 k 9 10111213141516 −60 −40 −20 0 dB (2) (c) Figure 4-2 (continued) . the zero-value segments Discrete-Signal Analysis and Design, By William E. Sabin Copyright 2008 John Wiley & Sons, Inc. 61 62 DISCRETE-SIGNAL ANALYSIS AND DESIGN Y 1 (i) := .25 ⋅W (i − 1). log 1 49 56 i=8 Y 3 (i) − Y 8 (i) Y 8 (i) 2 dB (4-1) 64 DISCRETE-SIGNAL ANALYSIS AND DESIGN The result is the ratio, in dB, between a three-sweep and an eight-sweep record. Another sequence that was. 4 Smoothing and Windowing In this chapter we consider ways to improve discrete sequences, including the reduction of data contamination and the improvement of certain time and frequency properties.