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

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 ...@@ -152,8 +152,18 @@ for t=1:sample_size
KalmanFilterGain = PredictedStateAndObservedCovariance/PredictedObservedVariance; KalmanFilterGain = PredictedStateAndObservedCovariance/PredictedObservedVariance;
StateVectorMean = PredictedStateMean + KalmanFilterGain*PredictionError; StateVectorMean = PredictedStateMean + KalmanFilterGain*PredictionError;
StateVectorVariance = PredictedStateVariance - KalmanFilterGain*PredictedObservedVariance*KalmanFilterGain'; StateVectorVariance = PredictedStateVariance - KalmanFilterGain*PredictedObservedVariance*KalmanFilterGain';
StateVectorVarianceSquareRoot = chol(StateVectorVariance)'; [StateVectorVarianceSquareRoot, p]= chol(StateVectorVariance,'lower');
PredictedObservedVarianceSquareRoot = chol(PredictedObservedVariance)' ; if p
LIK=-Inf;
lik(t)=-Inf;
return
end
[PredictedObservedVarianceSquareRoot, p]= chol(PredictedObservedVariance,'lower');
if p
LIK=-Inf;
lik(t)=-Inf;
return
end
end end
lik(t) = log( probability2(0,PredictedObservedVarianceSquareRoot,PredictionError) ) ; lik(t) = log( probability2(0,PredictedObservedVarianceSquareRoot,PredictionError) ) ;
end 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