mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-10 20:42:39 +02:00
some minor edit to Bernoulli
This commit is contained in:
parent
12c3877b50
commit
cd3bcee11c
1 changed files with 4 additions and 18 deletions
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2012, 2013 The GPy authors
|
||||
# Copyright (c) 2012, 2013 The GPy authors (see AUTHORS.txt)
|
||||
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
||||
|
||||
import numpy as np
|
||||
|
|
@ -16,8 +16,8 @@ class Bernoulli(Likelihood):
|
|||
p(y_{i}|\\lambda(f_{i})) = \\lambda(f_{i})^{y_{i}}(1-f_{i})^{1-y_{i}}
|
||||
|
||||
.. Note::
|
||||
Y is expected to take values in {-1, 1}
|
||||
Probit likelihood usually used
|
||||
Y is expected to take values in {-1, 1} TODO: {0, 1}??
|
||||
link function should have the domain [0, 1], e.g. probit (default) or Heaviside
|
||||
|
||||
.. See also::
|
||||
likelihood.py, for the parent class
|
||||
|
|
@ -68,9 +68,8 @@ class Bernoulli(Likelihood):
|
|||
N = std_norm_pdf(a)
|
||||
mu_hat = v_i/tau_i + sign*N/Z_hat/np.sqrt(tau_i)
|
||||
sigma2_hat = (1. - a*N/Z_hat - np.square(N/Z_hat))/tau_i
|
||||
if np.any(np.isnan([Z_hat, mu_hat, sigma2_hat])):
|
||||
stop
|
||||
else:
|
||||
#TODO: do we want to revert to numerical quadrature here?
|
||||
raise ValueError("Exact moment matching not available for link {}".format(self.gp_link.__name__))
|
||||
|
||||
return Z_hat, mu_hat, sigma2_hat
|
||||
|
|
@ -198,19 +197,6 @@ class Bernoulli(Likelihood):
|
|||
d3logpdf_dlink3 = 2*(y/(link_f**3) - (1-y)/((1-link_f)**3))
|
||||
return d3logpdf_dlink3
|
||||
|
||||
def _mean(self, gp):
|
||||
"""
|
||||
Mass (or density) function
|
||||
"""
|
||||
return self.gp_link.transf(gp)
|
||||
|
||||
def _variance(self, gp):
|
||||
"""
|
||||
Mass (or density) function
|
||||
"""
|
||||
p = self.gp_link.transf(gp)
|
||||
return p*(1.-p)
|
||||
|
||||
def samples(self, gp):
|
||||
"""
|
||||
Returns a set of samples of observations based on a given value of the latent variable.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue