# How do you do signal averaging on a realtime data?

Smoothing algorithms implemented by me

1. Exponential smoothing - https://www.openprocessing.org/sketch/771368
2. Moving Mean - https://www.openprocessing.org/sketch/540696

For example - a1+a2+a3+a4+... aN = A/N ..... is an average of all the a's which isn't same as ---> (((a/1+a2)/2 + a3)/3 +a4)/2 .... so on...

can anyone explain me how wrong I am or explain me signal averaging correctly?

@Greyfrog. Here are the descriptions of four different kinds of averaging operations:

• Regarding my above exponential averager, that network (block diagram) is the traditional network given in the DSP textbooks. In practice the 'multiply-by-alpha' operation should be performed on the output of the network instead of at the network's input. The reason for this is explained at: dsprelated.com/showarticle/1249.php Feb 28 '20 at 23:30
• can you explain me how can I do realtime signal averaging? Thank you Richard :) Feb 29 '20 at 13:05
• Mr Lyons’ description here is a pretty comprehensive review of real time averaging. He also has written the literal book on digital signal processing, which is an excellent resource and as I recall goes into this topic more extensively. If you are looking for something relatively lightweight and free, you might check out the scientist and engineers guide to DSP, or some of the free material on DSPRELATED. If you are still having trouble, you may want to rephrase your question to be a bit more specific. Feb 29 '20 at 17:37
• @Greyfrog. I am willing to help if I am able, but your question surprises me. Do you understand the meaning of the $y(n)$ time-domain and $H_{ma}(z)$ z-domain equations in my Answer's "Nonrecursive real-time N-point moving average" section? Are you able to implement the processing of the "Nonrecursive real-time N-point moving average" network? The "scientist and engineers guide" material mentioned by the helpful and gracious Dan Szabo can be found at: lad.dsc.ufcg.edu.br/DSP/ch15.pdf Feb 29 '20 at 18:39

Classically, an averager is supposed, when applied to a constant, to yield the same value as an output. Here, with:

$$u_3=\left( \left(\left(a_1\right/1 ) + a_2\right)/2+a_3\right)/3$$

when you set $$a_k=a$$, then you get

$$\left( \left(\left(a\right/1 ) + a\right)/2+a\right)/3 = a (2/2+1)/3 = 2a/3$$

Indeed, you have $$u_{n+1} = (u_{n}+a_{n+1})/(n+1)$$. With constant $$a_k$$, this boils down to the series:

$$v_{n+1} = (v_{n}+1)/(n+1)$$

with $$v_1=1$$. With a quick napkin check, this decreases roughly as $$1/n$$, and goes to zero. You would have better results with the recursion:

$$u_3=\left( \left(\left(a_1\right/1 ) + (2-1)a_2\right)/2+(3-1)a_3\right)/3$$

or $$u_{n+1} = (u_{n}+na_{n+1})/(n+1)$$

I didn't know never it is useful, or if it even has a name. The recursive averager takes a "dual" form:

$$u_{n+1} = (nu_{n}+a_{n+1})/(n+1)$$

You could use incremental averaging. https://math.stackexchange.com/questions/106700/incremental-averageing

• this doesn't seem to answer the question. Mar 5 '20 at 12:41
• I had used once used incremental averaging for real time calculation. So I thought I could suggest that. Mar 5 '20 at 14:09