Hi, sfrwmaker,
Thanks for your great work!
Recently, I read your code. I could not understand the “exponential moving average” part.
The following formula is the one get from:
http://www.alglib.net/time-series/moving-average-filter.php
EMA(t) = α·X(t) + (1-α)·EMA(t-1)
but the code from your project is diffrent:
int32_t empAverage(uint32_t emp_data, uint8_t emp_k, int32_t v) {
uint8_t round_v = emp_k >> 1;
emp_data += v - (emp_data + round_v) / emp_k;
return (emp_data + round_v) / emp_k;
}
Hi, sfrwmaker, Thanks for your great work! Recently, I read your code. I could not understand the “exponential moving average” part. The following formula is the one get from: http://www.alglib.net/time-series/moving-average-filter.php EMA(t) = α·X(t) + (1-α)·EMA(t-1)
but the code from your project is diffrent: int32_t empAverage(uint32_t emp_data, uint8_t emp_k, int32_t v) { uint8_t round_v = emp_k >> 1; emp_data += v - (emp_data + round_v) / emp_k; return (emp_data + round_v) / emp_k; }
Is this a mistake?