Digital Signal Processing Reference
In-Depth Information
Fig. 2.27 Moving average of
a stock price over 35 days
using a 10-tap FIR filter. Note
that the first M - 1 = 9
samples are inaccurate due to
insufficient information at
start
15
10
Global Average
5
0
10
20
Time (days)
y ð n Þ¼ 1
3 ½ x ð n Þþ x ð n 1 Þþ x ð n 2 Þ
ð 2 : 23 Þ
For example, at n ¼ 2 ; y ð 2 Þ¼ 3 ½ x ð 2 Þþ x ð 1 Þþ x ð 0 Þ; at n ¼ 3 ; y ð 3 Þ¼ 3 ½ x ð 3 Þþ
x ð 2 Þþ x ð 1 Þ: Comparing the above Eq. ( 2.23 ) with the general FIR equation:
y ð n Þ¼ h ð n Þ x ð n Þ¼ X
N 1
h ð k Þ x ð n k Þ
k ¼ 0
¼ h 0 ð n Þþ h 1 x ð n 1 Þþþ h N 1 x ½ n ð N 1 Þ
it is seen that ( 2.23 ) represents an FIR filter with N = 3 taps: h ð 0 Þ¼ h ð 1 Þ¼
h ð 2 Þ¼ 3 : Although these filter coefficients are all equal in this case they can be
different in general. For example, in the stock market studies one may give more
weight (importance) to the current sample [i.e., x(n)] than to others, e.g.,
h ð 0 Þ¼ 0 : 5 ;
50% weight to the current price (today)
h ð 1 Þ¼ 0 : 3 ;
30% weight to the previous price (yesterday)
h ð 2 Þ¼ 0 : 2 ;
20% weight to the first price (2 days ago)
Figure ( 2.27 ) shows an example of a changing price over 35 days along with the
overall average and the moving average with h(n) = [.1 .1 .1 .1 .1 .1 .1 .1 .1 .1]
(M = 10 taps with equal weight).
2.6.6.3 The Digital Differentiator
Time Domain Approach
The derivative of a signal x(t), dx(t)/dt, can be approximated in the digital domain
(when the sampling period T s is small and x(t) is slowly varying) by the relation:
y ð n Þ¼½ x ð n Þ x ð n 1 Þ= T s
ð 2 : 24 Þ
as shown in Fig. ( 2.28 ). Comparing with the general form of an FIR filter:
 
Search WWH ::




Custom Search