Commit 79b42ec9 authored by Stéphane Adjemian's avatar Stéphane Adjemian Committed by GitHub

Merge pull request #8 from JohannesPfeifer/patch-3

Properly terminate nonlinear_kalman_filter if non-positive definite m…
parents 285d5c17 ddc5b5b6
......@@ -152,8 +152,18 @@ for t=1:sample_size
KalmanFilterGain = PredictedStateAndObservedCovariance/PredictedObservedVariance;
StateVectorMean = PredictedStateMean + KalmanFilterGain*PredictionError;
StateVectorVariance = PredictedStateVariance - KalmanFilterGain*PredictedObservedVariance*KalmanFilterGain';
StateVectorVarianceSquareRoot = chol(StateVectorVariance)';
PredictedObservedVarianceSquareRoot = chol(PredictedObservedVariance)' ;
[StateVectorVarianceSquareRoot, p]= chol(StateVectorVariance,'lower');
if p
LIK=-Inf;
lik(t)=-Inf;
return
end
[PredictedObservedVarianceSquareRoot, p]= chol(PredictedObservedVariance,'lower');
if p
LIK=-Inf;
lik(t)=-Inf;
return
end
end
lik(t) = log( probability2(0,PredictedObservedVarianceSquareRoot,PredictionError) ) ;
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment