Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 卡尔曼滤波最优性_Matlab_Filter_Kalman Filter - Fatal编程技术网

Matlab 卡尔曼滤波最优性

Matlab 卡尔曼滤波最优性,matlab,filter,kalman-filter,Matlab,Filter,Kalman Filter,我试图理解卡尔曼滤波器的最优性。根据维基百科:“从理论上可以知道,如果a)模型与真实系统完全匹配,b)输入噪声为白色,c)噪声协方差完全已知,则卡尔曼滤波器是最优的。”。但这种最优性意味着什么?我如何测试它 我在Kalman滤波器上找到了student daves的例子,并开始测试它。我通过改变卡尔曼滤波器估计的噪声参数来做到这一点。我通过取估计误差的均方根对结果进行排序,并期望在噪声方差与实际噪声参数匹配时获得最佳结果。我错了。为什么会这样 以下是我在测试中使用的matlab代码(根据Stud

我试图理解卡尔曼滤波器的最优性。根据维基百科:“从理论上可以知道,如果a)模型与真实系统完全匹配,b)输入噪声为白色,c)噪声协方差完全已知,则卡尔曼滤波器是最优的。”。但这种最优性意味着什么?我如何测试它

我在Kalman滤波器上找到了student daves的例子,并开始测试它。我通过改变卡尔曼滤波器估计的噪声参数来做到这一点。我通过取估计误差的均方根对结果进行排序,并期望在噪声方差与实际噪声参数匹配时获得最佳结果。我错了。为什么会这样

以下是我在测试中使用的matlab代码(根据Student Daves示例修改)

这是结果图:


为什么我错了?当估计模型与实际模型完全一致时,为什么结果不是最好的?提前感谢:)

在您上面提到的情况下,即1。模型是正确的。噪声是具有已知方差的高斯白噪声卡尔曼滤波器是最优的,因为它是将达到最小均方误差(MMSE)和CRB(Cramer-Rao界)的估计器


我会对数字结果发表评论,但上面的代码不起作用,OP发布的结果链接也被破坏了。卡尔曼滤波器是一种有效的迭代估计器,仅在最小均方误差意义下才是最优的,即该估计器的推导目的是最小化平方新息过程(假定为零均值白高斯过程)的期望值。在这种情况下,状态协方差矩阵是无偏估计器所能得到的最低值(尽可能高),等于CRB。

它是最优的,因为它最小化了实际值和估计值之间的预期误差值。但这只适用于线性解领域,当噪声为零均值、不相关且为白色时。谢谢你回答Mendi Barel,但我仍然不理解结果。这个例子不是这样吗?噪声为零均值、不相关和高斯噪声。如果均方根不起作用,我如何测量最优性?嗨,Nir,谢谢你的回答!如果你能把它扩展一点就好了,不过,特别是简单地解释一下MMSE和CRB是关于什么的,并对OP的数字结果进行评论。
% written by StudentDave
%for licensing and usage questions
%email scienceguy5000 at gmail. com

%Bayesian Ninja tracking Quail using kalman filter

clear all
% define our meta-variables (i.e. how long and often we will sample)
duration = 10  %how long the Quail flies
dt = .1;  %The Ninja continuously looks for the birdy,
%but we'll assume he's just repeatedly sampling over time at a fixed interval

% Define update equations (Coefficent matrices): A physics based model for where we expect the Quail to be [state transition (state + velocity)] + [input control (acceleration)]
A = [1 dt; 0 1] ; % state transition matrix:  expected flight of the Quail (state prediction)
B = [dt^2/2; dt]; %input control matrix:  expected effect of the input accceleration on the state.
C = [1 0]; % measurement matrix: the expected measurement given the predicted state (likelihood)
%since we are only measuring position (too hard for the ninja to calculate speed), we set the velocity variable to
%zero.

% define main variables
u = 1.5; % define acceleration magnitude
Q= [0; 0]; %initized state--it has two components: [position; velocity] of the Quail
Q_estimate = Q;  %x_estimate of initial location estimation of where the Quail is (what we are updating)
QuailAccel_noise_mag =0.05; %process noise: the variability in how fast the Quail is speeding up (stdv of acceleration: meters/sec^2)
NinjaVision_noise_mag =10;  %measurement noise: How mask-blinded is the Ninja (stdv of location, in meters)
Ez = NinjaVision_noise_mag^2;% Ez convert the measurement noise (stdv) into covariance matrix
Ex = QuailAccel_noise_mag^2 * [dt^4/4 dt^3/2; dt^3/2 dt^2]; % Ex convert the process noise (stdv) into covariance matrix
P = Ex; % estimate of initial Quail position variance (covariance matrix)

% initize result variables
% Initialize for speed
Q_loc = []; % ACTUAL Quail flight path
vel = []; % ACTUAL Quail velocity
Q_loc_meas = []; % Quail path that the Ninja sees


% simulate what the Ninja sees over time
figure(2);clf
figure(1);clf
for t = 0 : dt: duration
    % Generate the Quail flight
    QuailAccel_noise = QuailAccel_noise_mag * [(dt^2/2)*randn; dt*randn];
    Q= A * Q+ B * u + QuailAccel_noise;
    % Generate what the Ninja sees
    NinjaVision_noise = NinjaVision_noise_mag * randn;
    y = C * Q+ NinjaVision_noise;
    Q_loc = [Q_loc; Q(1)];
    Q_loc_meas = [Q_loc_meas; y];
    vel = [vel; Q(2)];
    %iteratively plot what the ninja sees
    plot(0:dt:t, Q_loc, '-r.')
    plot(0:dt:t, Q_loc_meas, '-k.')
    axis([0 10 -30 80])
    hold on
end

%plot theoretical path of ninja that doesn't use kalman
plot(0:dt:t, smooth(Q_loc_meas), '-g.')

%plot velocity, just to show that it's constantly increasing, due to
%constant acceleration
%figure(2);
%plot(0:dt:t, vel, '-b.')


%% Do kalman filtering
Qa = 0.5*QuailAccel_noise_mag^2: 0.05*QuailAccel_noise_mag^2: 1.5*QuailAccel_noise_mag^2;
Ez3 = 0.5*Ez: 0.05*Ez: 1.5*Ez;
rms_tot = zeros(length(Qa), length(Ez3));
rms_tot2 = zeros(length(Qa), length(Ez3));
for i = 1:length(Qa)
    Ex2=Qa(i) * [dt^4/4 dt^3/2; dt^3/2 dt^2];
    for j=1:length(Ez3)
        Ez2=Ez3(j);
        %initize estimation variables
        Q_loc_estimate = []; %  Quail position estimate
        vel_estimate = []; % Quail velocity estimate
        Q= [0; 0]; % re-initized state
        P_estimate = P;
        P_mag_estimate = [];
        predic_state = [];
        predic_var = [];
        for t = 1:length(Q_loc)
            % Predict next state of the quail with the last state and predicted motion.
            Q_estimate = A * Q_estimate + B * u;
            predic_state = [predic_state; Q_estimate(1)] ;
            %predict next covariance
            P = A * P * A' + Ex2;
            predic_var = [predic_var; P] ;
            % predicted Ninja measurem  1ent covariance
            % Kalman Gain
            K = P*C'*inv(C*P*C'+Ez2);
            % Update the state estimate.
            Q_estimate = Q_estimate + K * (Q_loc_meas(t) - C * Q_estimate);
            % update covariance estimation.
            P =  (eye(2)-K*C)*P;
            %Store for plotting
            Q_loc_estimate = [Q_loc_estimate; Q_estimate(1)];
            vel_estimate = [vel_estimate; Q_estimate(2)];
            P_mag_estimate = [P_mag_estimate; P(2,2)];
        end
        rms_tot(i,j) = rms(Q_loc-Q_loc_estimate);
    end
end
close all;
figure;
surf(Qa, Ez3, rms_tot);
ylabel('measurement variance'); xlabel('model variance');