From e584cd604c3cf8926fc70593c0f969c0009ca1cf Mon Sep 17 00:00:00 2001 From: faridm69 <faridmohammadi69@gmail.com> Date: Fri, 18 Sep 2020 09:22:18 +0200 Subject: [PATCH] [BayesInference] modified normpdf function. --- .../BayesInference/BayesInference.py | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/BayesValidRox/BayesInference/BayesInference.py b/BayesValidRox/BayesInference/BayesInference.py index b5d7f5878..a1c214226 100644 --- a/BayesValidRox/BayesInference/BayesInference.py +++ b/BayesValidRox/BayesInference/BayesInference.py @@ -167,23 +167,18 @@ class BayesInference: stdPCE = np.hstack((stdPCE, self.stdPCEPriorPred[outputType])) # Expected value of variance (Assump: i.i.d stds) - varPCE = np.mean(stdPCE**2, axis=0) + # varPCE = np.mean(stdPCE**2, axis=0) + varPCE = np.var(stdPCE, axis=1) np.fill_diagonal(covMatrix_PCE, varPCE) - + covMatrix += covMatrix_PCE # Compute loglikelihood - # try: - # logL = multivariate_normal.logpdf(TotalOutputs, mean=Data, cov=covMatrix) - # except: - # logL = -np.inf - - logL = 0 - for i, y in enumerate(TotalOutputs): - res = Data - y - sigma = np.sqrt(covMatrix[i,i]) - logL += -0.5 * (np.sum((res / sigma)**2) - + 1*np.log(2*np.pi*sigma**2)) + try: + logL = multivariate_normal.logpdf(TotalOutputs, mean=Data, cov=covMatrix) + except: + logL = -np.inf + return logL #-------------------------------------------------------------------------------------------------------- -- GitLab