# Kalman filter to filter noise from acceleration data

I would like to apply a Kalman filter to remove noise from my measured acceleration data. The idea is then to compare the results obtained in this way whit the results obtained by applying a low-pass filter.

So, the Kalman filter equations are the following:

$x_k = Ax_{k-1}+q_{k-1}$

$z_k = Hx_k+r_k$

where $x$ is the state vector, $A$ is the transition matrix, $z$ is the vector of measurements and $H$ the observation matrix. $q$ and $r$ represent the process and measurement noise respectively.

Since I am working with one signal only (acceleration), the state vector $x$ is actually a scalar entity and so are all the other terms in the previous equations. In my case I had $A = 1$ and $H = 1$.

My understanding of the Kalman filter is that it computes an estimate of the input signal, therefore it is not a proper filter. So what I have to tune to smoothen the measured data is the $Q$ value (process noise covariance) in order to change the way in which the signal is estimated. The idea is to have a "worse" estimate in such a way that the peaks introduced by the noise are removed from the signal (which means the filter follows the original signal less accurately).

Is this the correct way to procede?

• "therefore it is not a proper filter" seems wrong. It's certainly a filter. You can set it up to be a smoother or a predictor, but the standard formulation is just a filter (calculate the current state estimate from the current measurements). Because of the simplicity of your signal model, perhaps just a simple first order smoother might be better? – Peter K. Dec 15 '15 at 16:40
• What I meant is that I am not defining a cut off frequency like I would do when using a Butterworth filter, for example. The filtering effect comes from the fact that I am using low values for the process noise covariance, thus saying that my model is a good estimate of the process although it might be not. Therefore what I am doing if find a compromise between good reproduction of the signal and smoothing. – Rhei Dec 16 '15 at 8:01
• I have been asked to make a comparison between the Kalman filter and the low-pass filter performance, so I cannot rely on a first order smoother although I might try it just to see how it behaves – Rhei Dec 16 '15 at 8:02
• OK! Thanks for the update. The fact is, though, that the KF will just be a low-pass(ish) filter once the Kalman gain converges. The trick will be selection of the process and measurement noise covariances. – Peter K. Dec 16 '15 at 9:55
• "it is not a proper filter"?? This is completely wrong. If your system is linear and the noise is Gaussian, no filter will compete Kalman filter. It is an optimal filter and it performs really really well. – CroCo Dec 18 '15 at 7:14