Skip to content

Commit

Permalink
error fix in posterior covariance
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusMNoack committed Aug 8, 2024
1 parent 5309c4d commit f6d6033
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion fvgp/gp_likelihood.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def _default_noise_function(self, x, hyperparameters):
return noise

def _measured_noise_function(self, x, hyperparameters):
return self.noise_variances
if len(x) == len(self.noise_variances): return self.noise_variances
else: return np.zeros((len(x))) + 0.00001

@staticmethod
def _default_dnoise_dh(x, hps):
Expand Down
6 changes: 3 additions & 3 deletions fvgp/gp_posterior.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ def posterior_covariance(self, x_pred, x_out=None, variance_only=False, add_nois

if add_noise and callable(self.likelihood_obj.noise_function):
noise = self.likelihood_obj.noise_function(x_pred, self.prior_obj.hyperparameters)
if issparse(noise): noise = noise.toarray()
assert isinstance(noise, np.ndarray) and np.ndim(noise) == 1
if len(x_pred) == len(noise):
v = v + np.diag(noise)
if S is not None: S = S + noise
v = v + noise
if S is not None: S = S + np.diag(noise)
else:
warnings.warn("Noise could not be added, you did not provide a noise callable at initialization")

Expand Down
1 change: 1 addition & 0 deletions tests/test_fvgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def prior_mean(x,hps):
res = my_gp1.posterior_mean_grad(x_pred,direction=0)
res = my_gp1.posterior_mean_grad(x_pred)
res = my_gp1.posterior_covariance(x_pred)
res = my_gp1.posterior_covariance(x_pred, add_noise = True)
res = my_gp1.posterior_covariance_grad(x_pred,direction=0)
res = my_gp1.gp_entropy(x_pred)
res = squared_exponential_kernel(1,1)
Expand Down

0 comments on commit f6d6033

Please sign in to comment.