# Source code for GPy.likelihoods.poisson

from __future__ import division

import numpy as np
from scipy import stats,special
import scipy as sp
from .likelihood import Likelihood

[docs]class Poisson(Likelihood):
"""
Poisson likelihood

.. math::
p(y_{i}|\\lambda(f_{i})) = \\frac{\\lambda(f_{i})^{y_{i}}}{y_{i}!}e^{-\\lambda(f_{i})}

.. Note::
Y is expected to take values in {0,1,2,...}
"""

def _conditional_mean(self, f):
"""
the expected value of y given a value of f
"""

"""

.. math::
p(y_{i}|\\lambda(f_{i})) = \\frac{\\lambda(f_{i})^{y_{i}}}{y_{i}!}e^{-\\lambda(f_{i})}

:param y: data
:type y: Nx1 array
:returns: likelihood evaluated for this point
:rtype: float
"""

"""

.. math::
\\ln p(y_{i}|\lambda(f_{i})) = -\\lambda(f_{i}) + y_{i}\\log \\lambda(f_{i}) - \\log y_{i}!

:param y: data
:type y: Nx1 array
:returns: likelihood evaluated for this point
:rtype: float

"""

"""

.. math::
\\frac{d \\ln p(y_{i}|\lambda(f_{i}))}{d\\lambda(f)} = \\frac{y_{i}}{\\lambda(f_{i})} - 1

:param y: data
:type y: Nx1 array
:returns: gradient of likelihood evaluated at points
:rtype: Nx1 array

"""

"""
The hessian will be 0 unless i == j

.. math::
\\frac{d^{2} \\ln p(y_{i}|\lambda(f_{i}))}{d^{2}\\lambda(f)} = \\frac{-y_{i}}{\\lambda(f_{i})^{2}}

:param y: data
:type y: Nx1 array
:returns: Diagonal of hessian matrix (second derivative of likelihood evaluated at points f)
:rtype: Nx1 array

.. Note::
Will return diagonal of hessian, since every where else it is 0, as the likelihood factorizes over cases
"""

"""

.. math::
\\frac{d^{3} \\ln p(y_{i}|\lambda(f_{i}))}{d^{3}\\lambda(f)} = \\frac{2y_{i}}{\\lambda(f_{i})^{3}}

:param y: data
:type y: Nx1 array
:returns: third derivative of likelihood evaluated at points f
:rtype: Nx1 array
"""

[docs]    def conditional_mean(self,gp):
"""
The mean of the random variable conditioned on one value of the GP
"""

[docs]    def conditional_variance(self,gp):
"""
The variance of the random variable conditioned on one value of the GP
"""