module HasGP.Covariance.SquaredExpARD
(
SquaredExponentialARD(..)
) where
import Numeric.LinearAlgebra
import HasGP.Types.MainTypes
import HasGP.Support.Linear
import HasGP.Support.Functions
import HasGP.Covariance.Basic
data SquaredExponentialARD = SquaredExponentialARD
{
fARD :: Double,
m :: DVector
}
instance CovarianceFunction SquaredExponentialARD where
trueHyper se = mapVector exp $ join [fromList [fARD se], m se]
covariance se x1 x2 = f2 * (exp (((1/2)) * (xAxDiag diff newM2)))
where
diff = x1 x2
f2 = exp (fARD se)
newM2 = mapVector ((^^(2)) . exp) (m se)
dCovarianceDParameters se x1 x2 =
join [(fromList [dKDLogF]), dKDLogM]
where
diff = x1 x2
d = mapVector square diff
f2 = exp (fARD se)
m2 = mapVector exp (m se)
newM2 = mapVector (^^(2)) m2
dKDLogF = exp (((1/2)) * (xAxDiag diff newM2))
dKDLogM = scale (f2 * dKDLogF)
(zipVectorWith (*) d (mapVector (^^(3)) m2))
makeCovarianceFromList se (f:rest) =
if (length rest) == (dim $ (m se))
then SquaredExponentialARD f (fromList rest)
else error "SquaredExpARD needs the correct number of hyperparameters"
makeCovarianceFromList se _ =
error "SquaredExpARD needs the correct number of hyperparameters"
makeListFromCovariance se = (fARD se):(toList $ m se)