before issuing F singularity, check with rescaled F matrix: this spares lots of computing time when singularity only happens in the first KF step.
parent
09be021dcd
commit
73291b0b19
|
@ -158,6 +158,7 @@ else
|
||||||
LIKK={likk,dlikk};
|
LIKK={likk,dlikk};
|
||||||
end
|
end
|
||||||
|
|
||||||
|
rescale_prediction_error_covariance0=rescale_prediction_error_covariance;
|
||||||
while notsteady && t<=last
|
while notsteady && t<=last
|
||||||
s = t-start+1;
|
s = t-start+1;
|
||||||
if Zflag
|
if Zflag
|
||||||
|
@ -175,7 +176,12 @@ while notsteady && t<=last
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if rcond(F)<kalman_tol
|
if rcond(F)<kalman_tol
|
||||||
badly_conditioned_F = true;
|
sig=sqrt(diag(F));
|
||||||
|
if any(diag(F)<kalman_tol) || rcond(F./(sig*sig'))<kalman_tol
|
||||||
|
badly_conditioned_F = true;
|
||||||
|
else
|
||||||
|
rescale_prediction_error_covariance=1;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if badly_conditioned_F
|
if badly_conditioned_F
|
||||||
|
@ -191,6 +197,7 @@ while notsteady && t<=last
|
||||||
if rescale_prediction_error_covariance
|
if rescale_prediction_error_covariance
|
||||||
log_dF = log(det(F./(sig*sig')))+2*sum(log(sig));
|
log_dF = log(det(F./(sig*sig')))+2*sum(log(sig));
|
||||||
iF = inv(F./(sig*sig'))./(sig*sig');
|
iF = inv(F./(sig*sig'))./(sig*sig');
|
||||||
|
rescale_prediction_error_covariance=rescale_prediction_error_covariance0;
|
||||||
else
|
else
|
||||||
log_dF = log(det(F));
|
log_dF = log(det(F));
|
||||||
iF = inv(F);
|
iF = inv(F);
|
||||||
|
|
|
@ -84,6 +84,7 @@ oldK = Inf;
|
||||||
notsteady = 1;
|
notsteady = 1;
|
||||||
F_singular = true;
|
F_singular = true;
|
||||||
s = 0;
|
s = 0;
|
||||||
|
rescale_prediction_error_covariance0=rescale_prediction_error_covariance;
|
||||||
|
|
||||||
while notsteady && t<=last
|
while notsteady && t<=last
|
||||||
s = t-start+1;
|
s = t-start+1;
|
||||||
|
@ -110,7 +111,13 @@ while notsteady && t<=last
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if rcond(F)<kalman_tol
|
if rcond(F)<kalman_tol
|
||||||
badly_conditioned_F = true;
|
sig=sqrt(diag(F));
|
||||||
|
if any(diag(F)<kalman_tol) || rcond(F./(sig*sig'))<kalman_tol
|
||||||
|
badly_conditioned_F = true;
|
||||||
|
else
|
||||||
|
rescale_prediction_error_covariance=1;
|
||||||
|
end
|
||||||
|
% badly_conditioned_F = true;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if badly_conditioned_F
|
if badly_conditioned_F
|
||||||
|
@ -126,6 +133,7 @@ while notsteady && t<=last
|
||||||
if rescale_prediction_error_covariance
|
if rescale_prediction_error_covariance
|
||||||
log_dF = log(det(F./(sig*sig')))+2*sum(log(sig));
|
log_dF = log(det(F./(sig*sig')))+2*sum(log(sig));
|
||||||
iF = inv(F./(sig*sig'))./(sig*sig');
|
iF = inv(F./(sig*sig'))./(sig*sig');
|
||||||
|
rescale_prediction_error_covariance=rescale_prediction_error_covariance0;
|
||||||
else
|
else
|
||||||
log_dF = log(det(F));
|
log_dF = log(det(F));
|
||||||
iF = inv(F);
|
iF = inv(F);
|
||||||
|
|
Loading…
Reference in New Issue