From e464d2e4e36e7bd62431fb1d5d1de53b6845401e Mon Sep 17 00:00:00 2001
From: Marco Ratto <marco.ratto@ec.europa.eu>
Date: Tue, 25 Jan 2022 10:27:47 +0100
Subject: [PATCH] make computation of log(det(sigma)) robust numerically

---
 matlab/marginal_density.m | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/matlab/marginal_density.m b/matlab/marginal_density.m
index 489fb8cf61..d6c1dc046d 100644
--- a/matlab/marginal_density.m
+++ b/matlab/marginal_density.m
@@ -69,7 +69,7 @@ parameter_names = bayestopt_.name;
 save([M_.dname filesep 'Output' filesep M_.fname '_mean.mat'],'xparam1','hh','parameter_names','SIGMA');
 
 fprintf('Estimation::marginal density: I''m computing the posterior log marginal density (modified harmonic mean)... ');
-logdetSIGMA = log(det(SIGMA));
+logdetSIGMA = sum(log(eig(SIGMA)));
 invSIGMA = hh;
 marginal = zeros(9,2);
 linee = 0;
-- 
GitLab