1.4.4.32 libq_q15_ExpAvg_q15_q15_q1d15 Function
Exponential averaging
Description
Function libq_q15_ExpAvg_q15_q15_q1d15():
Exponential averaging implements a smoothing function based on the form: avg = avg * lamda + new * (1-lamda) In this implementation, is has been optimized as follows. avg = (avg - new) * lamda + new
The optimization precludes accurate processing of new numbers that differ from the current average by more than unity. If the difference is greater than unity or less than negative unity, the difference is saturated.
The effect is akin to a smaller lambda, e.g., the new value will have a greater weight than expected. If the smoothing is of data that is entirely positive or entirely negative, then the saturation will not be an issue.
Parameters
q15 S(k) Previous exponential average
q15 X(k) New value to be averaged in
q15 L exponential averaging constant in Q1.15
Returns
q15 result - S(k+1) = S(k)L + X(k)(1-L)
C
q15 libq_q15_ExpAvg_q15_q15_q1d15 (q15 prevAvgQ15 , q15 newMeasQ15 , q15 lamdaQ1d15 );