Too basic, I'm not sure anyone needs that to solve the task as basic would need to read an article, it's obvious.
> Tune by eyeballing lag vs. noise.
In any serious installations (more than a homelab) you want some numeric metrics, not eyeballing. E.g. management or next engineer may reasonably ask "why alpha is 0.8? what's the rationale, why not 0.85", you want some formula to show it's what we want.
You can choose their version of alpha by picking a cutoff frequency f and setting alpha = exp(-2*pi*f*dt) where dt is your sample rate. f will be the ≈-3dB point of your filter where frequencies above it are reduced by 0.707 or more.
That gives you the time constant for the 63% step response, but that's not quite the same thing as the 3-dB cutoff, due to frequency warping. I do this to get an alpha value for cutoff_Hz at a given sampling interval dt_s:
A perhaps interesting (and sometimes even useful) property of the 1D Kalman filter is that it becomes an EMA when it's in the "steady state" (the gain to which it converges asymptotically, in practice often quite fast).
Specifically:
alpha = (Q + 2*R - sqrt(Q^2 + 4*Q*R))/(2*R)
This also concretizes that the Kalman filter is not adaptive in the sense of adapting to the data. The filtering behavior is fully specified by the parameterization.
The sometimes useful part is that with this formulation you can get the alpha parameter for an EMA in terms of the sensor and process noises.
8 comments
[ 7.0 ms ] story [ 46.2 ms ] thread> Tune by eyeballing lag vs. noise.
In any serious installations (more than a homelab) you want some numeric metrics, not eyeballing. E.g. management or next engineer may reasonably ask "why alpha is 0.8? what's the rationale, why not 0.85", you want some formula to show it's what we want.
Specifically:
This also concretizes that the Kalman filter is not adaptive in the sense of adapting to the data. The filtering behavior is fully specified by the parameterization.The sometimes useful part is that with this formulation you can get the alpha parameter for an EMA in terms of the sensor and process noises.