I am trying to smooth my discrete-time data points using the method of WMA.

Currently, I am using n as the window size and the weight array, {n/(n(n+1)/2), (n-1)/(n(n+1)/2), ... , 1/(n(n+1)/2)}.

If the y-value of each point is irrelevant, I can just simply randomly choose my size n.

However in my case, I hope to reserve the original values of the data points to the best extent. Thus, I cannot choose a big window that averages everything to flat.

My cut-off freq. is 3Hz and the sampling rate is 50Hz.

How may I choose the size of the window n?

Thanks in advance!


Your normalized window is given by

$$w(n)=\frac{2}{N+1}\frac{N-n}{N},\quad n=0,1,\ldots,N-1$$

The window satisfies


which means that the gain of the corresponding moving average filter is 1 at DC.

For determining the cut-off frequency, we need to compute the frequency response of the window:


After some algebra you get


Now you need to find the value of $N$ for which the magnitude of (1) at the cut-off frequency $\theta_c=2\pi\frac{3Hz}{50Hz}$ becomes $1/\sqrt{2}$ (-3dB). Since $N$ must be integer you cannot get any desired cut-off frequency, but the given cut-off is approximately achieved by $N=9$, for which $|W(e^{j\theta_c})|=0.698$ (-3.13dB).

  • $\begingroup$ Thank you so much for the detailed calculation. I made a mistake just now. I have modified my weight array. Could you pls kindly edit your answer according to my updated weight array? I am really new to filter design and thus cannot duplicate ur working process... Thank you! $\endgroup$ – Sibbs Gambling Jun 14 '13 at 8:43
  • $\begingroup$ This is exactly the window I assumed you would be using. It now also includes the normalization factor I suggested. So the answer is correct as it stands. If you're happy with it, please accept the answer (by hitting the check mark button) to show that your question has been answered satisfactorily. $\endgroup$ – Matt L. Jun 14 '13 at 8:48
  • $\begingroup$ How does the expression above (1) come about, please? Also, can I say that my values within 3Hz are preserved (remain exactly the same)? because I need to use the values of the max and min value of the series, so if the values are distorted after the filter, then I have to do sth. else... $\endgroup$ – Sibbs Gambling Jun 17 '13 at 6:00
  • $\begingroup$ Another question: if I find that a bigger value for N actually gives a better performance by experiment, what are the effects when I raise the value of N. Say, now the calculation shows that I need to take N as 9. If I use it as 30, then will the cutoff freq. vary? Will the frequency response within 3Hz remain 1? Actually I do NOT need the frequency response to be 1. As long as the max and min are scaled by a same constant, that will be sufficient. Thanks! $\endgroup$ – Sibbs Gambling Jun 17 '13 at 6:12
  • $\begingroup$ If you increase $N$, the cutoff frequency will decrease, because you apply more averaging. You can plot the magnitude of (1) for different values of N to see the effect. Take a grid of frequencies $\theta\in [0,\pi]$, where $\pi$ corresponds to half the sampling rate, and compute $|W(e^{j\theta})|$ for different values of $N$. $\endgroup$ – Matt L. Jun 17 '13 at 6:50

Your Answer

