# Kalman Filter (System Identification Toolkit)

The Kalman filter is a linear optimum filter that minimizes the mean of the squared error recursively. The convergence rate of the Kalman filter is relatively fast, but the implementation is more complex than that of LMS-based algorithms.

Recall that the equation *J*(*k*) = *E*[*e*
^{2}(*k*)] defines the cost function. The following procedure lists the steps of the Kalman filter algorithm.

- Initialize the parametric vector using a small positive number ε.

- Initialize the data vector .

- Initialize the
*k*×*k*matrix(0).*P*

- For
*k*= 1, update the data vector based on and the current input data*u*(*k*) and output data*y*(*k*). - Compute the predicted response by solving the following equation.

- Compute the error
*e*(*k*) by solving the following equation.

- Update the Kalman gain vector defined by the following equation.
*Q*_{M}is the measurement noise and(*P**k*) is a*k*×*k*matrix whose initial value is defined by(0) in step 3.*P* - Update the parametric vector .

- Update the
(*P**k*) matrix.*Q*_{P}is the correlation matrix of the process noise. - Stop if the error is small enough, else set
*k*=*k*+ 1 and repeat steps 4–10.