inline vectord KernelModel::computeCrossCorrelation(const vecOfvec& XX, const vectord &query) { vectord knx(XX.size()); computeCrossCorrelation(XX,query,knx); return knx; }
ProbabilityDistribution* StudentTProcessNIG::prediction(const vectord &query) { double kq = computeSelfCorrelation(query); vectord kn = computeCrossCorrelation(query); vectord phi = mMean.getFeatures(query); vectord v(kn); inplace_solve(mL,v,ublas::lower_tag()); vectord rq = phi - prod(v,mKF); vectord rho(rq); inplace_solve(mD,rho,ublas::lower_tag()); double yPred = inner_prod(phi,mWMap) + inner_prod(v,mVf); double sPred = sqrt( mSigma * (kq - inner_prod(v,v) + inner_prod(rho,rho))); if ((boost::math::isnan(yPred)) || (boost::math::isnan(sPred))) { throw std::runtime_error("Error in prediction. NaN found."); } d_->setMeanAndStd(yPred,sPred); return d_; }
ProbabilityDistribution* GaussianProcessNormal::prediction(const vectord &query) { double kq = (*mKernel)(query, query);; vectord kn = computeCrossCorrelation(query); vectord phi = mMean->getFeatures(query); vectord v(kn); inplace_solve(mL,v,ublas::lower_tag()); vectord rq = phi - prod(v,mKF); vectord rho(rq); inplace_solve(mD,rho,ublas::lower_tag()); double yPred = inner_prod(phi,mWMap) + inner_prod(v,mVf); double sPred = sqrt( mSigma * (kq - inner_prod(v,v) + inner_prod(rho,rho))); if ((boost::math::isnan(yPred)) || (boost::math::isnan(sPred))) { FILE_LOG(logERROR) << "Error in prediction. NaN found."; exit(EXIT_FAILURE); } d_->setMeanAndStd(yPred,sPred); return d_; }
ProbabilityDistribution* GaussianProcess::prediction(const vectord &query) { const double kq = computeSelfCorrelation(query); const vectord kn = computeCrossCorrelation(query); vectord vd(kn); inplace_solve(mL,vd,ublas::lower_tag()); double basisPred = mMean.muTimesFeat(query); double yPred = basisPred + ublas::inner_prod(vd,mAlphaV); double sPred = sqrt(mSigma*(kq - ublas::inner_prod(vd,vd))); d_->setMeanAndStd(yPred,sPred); return d_; }
ProbabilityDistribution* GaussianProcessML::prediction( const vectord &query ) { double kq = computeSelfCorrelation(query); vectord kn = computeCrossCorrelation(query); vectord phi = mMean.getFeatures(query); vectord v(kn); inplace_solve(mL,v,ublas::lower_tag()); vectord rq = phi - prod(v,mKF); vectord rho(rq); inplace_solve(mL2,rho,ublas::lower_tag()); double yPred = inner_prod(phi,mWML) + inner_prod(v,mAlphaF); double sPred = sqrt( mSigma * (kq - inner_prod(v,v) + inner_prod(rho,rho))); d_->setMeanAndStd(yPred,sPred); return d_; }