23 #include "ublas_trace.hpp" 29 namespace ublas = boost::numeric::ublas;
31 GaussianProcess::GaussianProcess(
size_t dim, Parameters params,
32 const Dataset& data, MeanModel& mean,
34 ConditionalBayesProcess(dim, params, data, mean, eng)
36 mSigma = params.sigma_s;
37 d_ =
new GaussianDistribution(eng);
41 GaussianProcess::~GaussianProcess()
50 return negativeLogLikelihood();
56 const matrixd K = computeCorrMatrix();
57 const size_t n = K.size1();
61 vectord alpha(mData.mY-mMean.muTimesFeat());
62 inplace_solve(L,alpha,ublas::lower_tag());
63 double loglik = ublas::inner_prod(alpha,alpha)/(2*mSigma);
64 loglik += utils::log_trace(L);
70 const double kq = computeSelfCorrelation(query);
71 const vectord kn = computeCrossCorrelation(query);
75 inplace_solve(mL,vd,ublas::lower_tag());
76 double basisPred = mMean.muTimesFeat(query);
77 double yPred = basisPred + ublas::inner_prod(vd,mAlphaV);
78 double sPred = sqrt(mSigma*(kq - ublas::inner_prod(vd,vd)));
80 d_->setMeanAndStd(yPred,sPred);
87 const size_t n = mData.getNSamples();
89 mAlphaV.resize(n,
false);
90 mAlphaV = mData.mY-mMean.muTimesFeat();
91 inplace_solve(mL,mAlphaV,ublas::lower_tag());
Namespace of the library interface.
ProbabilityDistribution * prediction(const vectord &query)
Function that returns the prediction of the GP for a query point in the hypercube [0...
double negativeTotalLogLikelihood()
Computes the negative log likelihood of the data for all the parameters.
double negativeLogLikelihood()
Computes the negative log likelihood of the data.
size_t cholesky_decompose(const MATRIX &A, TRIA &L)
decompose the symmetric positive definit matrix A into product L L^T.
Standard zero mean gaussian process with noisy observations.
void precomputePrediction()
Precompute some values of the prediction that do not depends on the query.