23 #include "ublas_trace.hpp" 29 namespace ublas = boost::numeric::ublas;
31 GaussianProcessML::GaussianProcessML(
size_t dim, Parameters params,
33 MeanModel& mean, randEngine& eng):
34 HierarchicalGaussianProcess(dim, params, data, mean, eng)
36 d_ =
new GaussianDistribution(eng);
41 GaussianProcessML::~GaussianProcessML()
58 double kq = computeSelfCorrelation(query);
59 vectord kn = computeCrossCorrelation(query);
60 vectord phi = mMean.getFeatures(query);
63 inplace_solve(
mL,v,ublas::lower_tag());
65 vectord rq = phi - prod(v,mKF);
68 inplace_solve(mL2,rho,ublas::lower_tag());
70 double yPred = inner_prod(phi,mWML) + inner_prod(v,mAlphaF);
71 double sPred = sqrt(
mSigma * (kq - inner_prod(v,v)
72 + inner_prod(rho,rho)));
74 d_->setMeanAndStd(yPred,sPred);
80 size_t n = mData.getNSamples();
81 size_t p = mMean.nFeatures();
84 inplace_solve(
mL,mKF,ublas::lower_tag());
86 matrixd FKF = prod(trans(mKF),mKF);
91 inplace_solve(
mL,Ky,ublas::lower_tag());
96 mAlphaF = mData.
mY - prod(mWML,mMean.
mFeatM);
97 inplace_solve(
mL,mAlphaF,ublas::lower_tag());
98 mSigma = inner_prod(mAlphaF,mAlphaF)/(n-p);
Gaussian process with ML parameters.
ProbabilityDistribution * prediction(const vectord &query)
Function that returns the prediction of the GP for a query point in the hypercube [0...
Namespace of the library interface.
double negativeTotalLogLikelihood()
Computes the negative log likelihood of the data for all the parameters.
matrixd mL
Cholesky decomposition of the Correlation matrix.
double mSigma
Signal variance.
size_t cholesky_decompose(const MATRIX &A, TRIA &L)
decompose the symmetric positive definit matrix A into product L L^T.
double negativeLogLikelihood()
Computes the negative log likelihood and its gradient of the data.
void cholesky_solve(const TRIA &L, MATRIX &x, ublas::lower)
solve system L L^T x = b inplace
matrixd mFeatM
Value of the mean features at the input points.
void precomputePrediction()
Precompute some values of the prediction that do not depends on the query.