Skip to content

Commit

Permalink
Add exact variational expectation implementation for Gamma likelihood
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Dec 11, 2023
1 parent f3b9883 commit 0c6134a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions mogptk/gpr/likelihood.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,11 +626,20 @@ def log_prob(self, X, y, f):
p -= self.shape()*self.link(f).log()
return p # NxQ

def variational_expectation(self, X, y, mu, var):
# y,mu,var: Nx1
if self.link != exp:
super().variational_expectation(X, y, mu, var)

p = -self.shape()*mu
p -= torch.lgamma(self.shape())
p += (self.shape() - 1.0) * y.log()
p -= y * torch.exp(var/2.0 - mu)
return p.sum()

def conditional_mean(self, X, f):
return self.shape()*self.link(f)

#TODO: implement variational_expectation

def conditional_sample(self, X, f):
if self.link != exp:
raise ValueError("only exponential link function is supported")
Expand Down

0 comments on commit 0c6134a

Please sign in to comment.