How to determine initial values in Kalman Filter I have EEG signal and exract PSD feature from it, then must apply it a noise reduction algorithm, I used Kalman filter,


but the output signal in the paper is much smoother than my output and
vertical axis is different in my case


I think that is because of Kalman filter initialization; initial state and predict.

Here is my output and paper output.


Papers output:


Mine :




Here is MATLAB code:

N = length(z);          % number of Klamn filter iterations
Qfactor = 1;            % process noise mult factor
Rfactor = 1;          % measurement noise mult factor
F = [ 1   2            % update matrix  
      0   1 ];
H = [ 1   0 ];            % measurement matrix
sigmaQ = 5e-5;  
sigmaR = 1;
Q = sigmaQ^2 * [ 8/3  2     % process noise covariance matrix
                  2   2 ];
R = sigmaR^2 * [ 1 ];         % measurement noise covariance
P = zeros(2, 2, N);
x = zeros(2, N);
x(:,1) = [ 0
           0 ];
P(:,:,1) = Q;

for i=2:N
    [xpred, Ppred] = predict(x(:,i-1), P(:,:,i-1), F, Q);
    [nu, S] = innovation(xpred, Ppred, z(i), H, R);
    [x(:,i), P(:,:,i)] = innovation_update(xpred, Ppred, nu, S, H);
end


plot(x(1,2:N),'b');

The functions:


Prediction

function [xpred, Ppred] = predict(x, P, F, Q)
 xpred = F * x;
 Ppred = F * P * F' + Q;
Inovation :

function [nu, S] = innovation(xpred, Ppred, z, H, R)
 nu = z - H * xpred;                   %% innnvoation
 S = R + H * Ppred * H';                 %% innovation covariance
and Inovation update :

function [xnew, Pnew] = innovation_update(xpred, Ppred, nu, S, H)
 K = Ppred * H' * inv(S);                 %% Kalman gain
 xnew = xpred + K * nu;                  %% new state
 Pnew = Ppred - K * S * K';              %% new covariance
but the output signal in the paper is much smoother than my output and


I don't know which paper we're referring to, but it's far from uncommon that you'd smoothen your output for plotting – it would be adequate to specify how you did that, but notice that this sadly doesn't mean everyone adheres to that practice.


  vertical axis is different in my case


that might just be a scaling error, and is not necessarily bad. Again, we don't know which paper is about and whether you're working on exactly the same data, but the fact alone that your line is much thinner and looks like it has more points indicates that they applied some smoothing and/or normalization.


  I think that is because of Kalman filter initialization; initial state and predict.


I don't see indications for that. On the contrary, assuming things converge, I'd say your initial state is fine.