On 2019-10-01 12:17, Johannes Berg wrote:
> 
>> This change replaces the EWMA implementation with a moving average that's
>> designed to significantly reduce lag while keeping a bigger window size
>> by being better at filtering out noise.
>> 
>> It is only slightly more expensive than the simple EWMA and still avoids
>> divisions in its calculation.
>> 
>> The algorithm is adapted from an implementation intended for a completely
>> different field (stock market trading), where the tradeoff of lag vs
>> noise filtering is equally important. It is based on the "smoothing filter"
>> from http://www.stockspotter.com/files/PredictiveIndicators.pdf.
>> 
>> I have adapted it to fixed-point math with some constants so that it uses
>> only addition, bit shifts and multiplication
>> 
> 
> Would it be worth pulling that out into similar helpers to EWMA in
> average.h, perhaps even in the same file?
> 
> You need to keep a bit more state, but essentially the same API should
> work since EWMA already declares the "struct ewma_something" once you
> use the DECLARE_EWMA().
Might be useful, yes. The main issue here is that the period / window
size has to be hardcoded through the coefficient values, unless we find
a way to do floating point math, including exp() and cos() at compile
time, including conversion to fixed point.

- Felix

Reply via email to