# Kalman filter

## Use a Savitzky-Golay filter

Kalman filters suck. They are model based and tied closely to the accurate model of a specific problem domain (for example, airplane flight dynamics, which may be unique to a specific aircraft.). For a good, yet general purpose filter that just looks at the numbers and doesn't care about the application domain and need no model of the sensor data, then consider the Savitzky-Golay (in IIR and FIR varieties).

At least, this is what I was left with feeling about the Kalman filter when I thought to use it to filter Geiger Counter detection events, and to filter accelerometer sensor readings. Maybe I was doing it wrong and I made it harder than it needed to be, so I came up with a mistaken notion.

See:

• "Generalized IIR Savitzky-Golay Filters: Derivation, Parameterization, Realization and an Adaptive Configuration" by Hugh Lachlan Kennedy. Quoting the author advising how to filter mobile phone acceleromter sensor output (sensor fusion), he said, "Use recursive filters to fit a polynomial to each of your channels, using discounted least-squares regression. Monitor the vector of estimated model coefficients, produced by your filter bank (i.e. the Laguerre spectrum), for sudden changes. A more reliable method (to reduce false alarms) would be to look for squared changes that are large relative to the estimate of the sensor noise variance, which is recursively derived from the residual of the polynomial fit..." He answers another question about general purpose sensor fusion and anomaly detection, "For anomaly detection in data streams with a uniform sampling period I like using low-order IIR filters designed using polynomial regression. Using an IIR filter, with an exponentially decaying weight to analyse the data allows long histories to be processed efficiently using recursion. The variance of the estimate is also estimated recursively. So any measurements that are beyond some multiple of the estimated std dev may be declared as outliers/anomalies.

I guess most people would use a Kalman filter for this sort of thing, Which is fine if you have good prior knowledge of the process and the measurement stats. Using polynomials is great if all you know is that your process is confined to the very low-frequency region of the spectrum, so that a simple smoother suffices."

• "Multidimensional Digital Smoothing Filters for Target Detection" by Hugh L. Kennedy, published: Signal Processing, Volume 114, September 2015, Pages 251-264