mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-04-27 05:46:24 +02:00
Initial commit, setting up the laplace approximation for a student t
This commit is contained in:
parent
67248ab7c2
commit
68eb83955c
5 changed files with 175 additions and 0 deletions
51
python/likelihoods/likelihood_function.py
Normal file
51
python/likelihoods/likelihood_function.py
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import GPy
|
||||
from scipy.special import gamma, gammaln
|
||||
|
||||
class student_t(GPy.likelihoods.likelihood_function):
|
||||
"""Student t likelihood distribution
|
||||
For nomanclature see Bayesian Data Analysis 2003 p576
|
||||
|
||||
Laplace:
|
||||
Needs functions to calculate
|
||||
ln p(yi|fi)
|
||||
dln p(yi|fi)_dfi
|
||||
d2ln p(yi|fi)_d2fi
|
||||
"""
|
||||
def __init__(self, deg_free, sigma=1):
|
||||
self.v = deg_free
|
||||
self.sigma = 1
|
||||
|
||||
def link_function(self, y_i, f_i):
|
||||
"""link_function $\ln p(y_i|f_i)$
|
||||
|
||||
:y_i: datum number i
|
||||
:f_i: latent variable f_i
|
||||
:returns: float(likelihood evaluated for this point)
|
||||
|
||||
"""
|
||||
e = y_i - f_i
|
||||
return gammaln((v+1)*0.5) - gammaln(v*0.5) - np.ln(v*np.pi*sigma)*0.5 - (v+1)*0.5*np.ln(1 + ((e/sigma)**2)/v)
|
||||
|
||||
def link_grad(self, y_i, f_i):
|
||||
"""gradient of the link function at y_i, given f_i w.r.t f_i
|
||||
|
||||
:y_i: datum number i
|
||||
:f_i: latent variable f_i
|
||||
:returns: float(gradient of likelihood evaluated at this point)
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def link_hess(self, y_i, f_i, f_j):
|
||||
"""hessian at this point (the hessian will be 0 unless i == j)
|
||||
i.e. second derivative w.r.t f_i and f_j
|
||||
|
||||
:y_i: @todo
|
||||
:f_i: @todo
|
||||
:f_j: @todo
|
||||
:returns: @todo
|
||||
|
||||
"""
|
||||
if f_i =
|
||||
pass
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue