# How does KalmanEstimator update the Kalman gain, process noise and state variable mean?

The first "Application" in the documentation for KalmanEstimator is copied below with additional variables for clarity.

Clear["Global*"];
a={{0.5,0.07869},{0,-0.60653}};
b={{0.0042,0.0104},{0.0786,0.00786}};
c={{1,0}};
d={{0,0}};
antenna=StateSpaceModel[{a,b,c,d},SamplingPeriod->0.1];
processVariance=0.01;
measurementVariance=0.001;
processCovariance={{processVariance}};
measurementCovariance={{measurementVariance}};
kalmanEstimate=KalmanEstimator[{antenna,All,1},
{processCovariance,measurementCovariance}];
kalmanFilter=SystemsModelExtract[kalmanEstimate,All,{3}];


The documentation uses u, y where I use inputSignal, noisySignal respectively.

inputSignal= Table[Sin[0.1*Pi*i],{i,100}];
processNoise=RandomReal[NormalDistribution[0,Sqrt[processVariance]],{100}];
measurementNoise=RandomReal[
NormalDistribution[0,Sqrt[measurementVariance]],{100}];
noisySignal=Flatten[OutputResponse[antenna,{inputSignal,processNoise}]]
+measurementNoise;
estimatedSignal=OutputResponse[kalmanFilter,{inputSignal,noisySignal}];


A Kalman Filter updates the state variables, state variable covariance matrix, and Kalman gain each time a new measurement arrives. However, kalmanFilter is defined above using Set rather than SetDelayed. Hence, the definition of kalmanFilter is never changed. Is kalmanFilter` above only used to get the recursive Kalman filter started?

Reference:

• the kalman filter is only for linear systems. So the linear kalman matrix is static and does not change/update. You may thought of the extended kalman filter? – Phab Sep 2 '15 at 13:24
• @Phab, I added a reference at the end of my question. I think I was wrong about some of the things that the Kalman filter updates after each measurement arrives, and I fixed that. Equations 1 through 6 in reference  above show how the state vector and it's covariance matrix are updated. Equation 7 in  above shows how the Kalman gain is updated. In the third column on page 129 in  above, it mentions "the Kalman filter equations that allow us to recursively calculate [an estimate of the state vector]". – Ted Ersek Sep 2 '15 at 20:40
• The assumptions used by KalmanEstimator is outlined in 'Details and Options'. The noise is assumed to be stationary, thus there is no update of the covariance matrix (but is obtained as a solution of a discrete Riccati equation) and gain (it is also constant). The equations for state (and output) updates is what is returned by KalmanEstimator. – Suba Thomas Sep 2 '15 at 21:23