{- | HasGP Gaussian Process Library. This module contains the definition for the standard log Phi likelihood. Copyright (C) 2011 Sean Holden. sbh11\@cl.cam.ac.uk. -} {- This file is part of HasGP. HasGP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. HasGP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with HasGP. If not, see <http://www.gnu.org/licenses/>. -} module HasGP.Likelihood.LogPhi ( LogPhi(..) ) where import Numeric.LinearAlgebra import HasGP.Types.MainTypes import HasGP.Support.Functions import HasGP.Likelihood.Basic {- | Value and first three derivatives of log Phi with respect to its parameter f. log p(y|f) = log \Phi (yf) where y is +1 or -1. -} data LogPhi = LogPhi instance LogLikelihood LogPhi where likelihood LogPhi y f = logPhi (y * f) dLikelihood LogPhi y f = y * nOverP where nOverP = (n f) / (phiIntegral (y * f)) ddLikelihood LogPhi y f = -(((nOverP)^2) + ((y * f) * nOverP)) where nOverP = (n f) / (phiIntegral (y * f)) dddLikelihood LogPhi y f = (2 * y * (nOverP^3)) + (((2 * f) + (y^2)) * (nOverP ^2)) - (y * (1 - (f^2)) * nOverP) where nOverP = (n f) / (phiIntegral (y * f))