12#ifdef GPR_LINALG_KOKKOS
30 const Eigen::VectorXd& x_ind,
31 const Eigen::VectorXd&
y)
39 return std::numeric_limits<double>::quiet_NaN();
48#ifdef GPR_LINALG_KOKKOS
61 log_det + 0.5 * (2.0 * hp_a_ + n) * std::log(1.0 + S / (2.0 * hp_b_));
64 data_rows_ =
static_cast<double>(n);
68 double n_adj = (n > 2) ?
static_cast<double>(n - 2) : 0.0;
69 tp_prefactor_ = (2.0 * hp_b_ + S) / (2.0 * hp_a_ + n_adj);
75 energy = edata + eprior;
84 if (data_rows_ <= 0.0)
return 1.0;
85 return (hp_a_ + 0.5 * data_rows_) / (hp_b_ + 0.5 * data_quadratic_);
92 data_quadratic_ = quadratic;
101 image1.
E.array() *= tp_prefactor_;
102 image1.
G.array() *= tp_prefactor_;
106 const Eigen::VectorXd& y_train)
117#ifdef GPR_LINALG_KOKKOS
128 const double n =
static_cast<double>(y_train.size());
129 const double n_adj = (n > 2.0) ? (n - 2.0) : 0.0;
130 const double denom = 2.0 * hp_a_ + n_adj;
131 if (!(denom > 0.0)) {
134 tp_prefactor_ = (2.0 * hp_b_ + S_k) / denom;
138 const Eigen::VectorXd& y_train,
const Eigen::VectorXd& b_local)
const
140 if (b_local.size() == 0)
return 1.0;
145 const Eigen::VectorXd& y_train,
const double y_dot_alpha)
const
147 if (!std::isfinite(y_dot_alpha))
return 1.0;
148 const double n =
static_cast<double>(y_train.size());
149 const double n_adj = (n > 2.0) ? (n - 2.0) : 0.0;
150 const double denom = 2.0 * hp_a_ + n_adj;
151 if (!(denom > 0.0))
return 1.0;
152 return (2.0 * hp_b_ + y_dot_alpha) / denom;
Linear algebra abstraction layer for GPR hot-path operations.
Student-t process regression, extending GP with heavy-tailed priors.
linalg::BackendContext & backend() const
virtual void calculateVariance(Observation &image1)
Compute predictive variance for energy and gradient. Corresponds to MATLAB get_variance....
bool decomposeCovarianceMatrix(const EigenMatrix &x, const Eigen::VectorXd &x_ind)
Evaluate and decompose the covariance matrix using Cholesky decomposition.
void calculateMeanPrediction(const Eigen::VectorXd &y)
Posterior mean prediction w.r.t energy. This function mimics the following step from the MATLAB code:...
std::shared_ptr< linalg::KokkosMolecularPosterior > device_posterior_
bool hasDevicePosterior() const noexcept
std::unique_ptr< SexpatCF > sexpat_cov_func
GaussianProcessRegression()
double hyperparameterDataTermScale() const override
Weight of the data term in the Student-t gradient.
void recordHyperparameterDataTerm(double rows, double quadratic) override
void refreshVariancePrefactor(const Eigen::VectorXd &y_train) override
Hook called inside calculateVarianceLaplace at each CCD grid point, right after calculateMeanPredicti...
void setHyperpriorParameters(double a, double b)
Set the inverse-gamma hyperprior parameters.
double localVariancePrefactor(const Eigen::VectorXd &y_train, const Eigen::VectorXd &b_local) const override
double evaluateEnergy(const EigenMatrix &x, const Eigen::VectorXd &x_ind, const Eigen::VectorXd &y) override
Evaluate the Student-t negative log marginal posterior.
void calculateVariance(Observation &image1) override
Compute predictive variance for energy and gradient. Corresponds to MATLAB get_variance....
double localVariancePrefactorFromQuadratic(const Eigen::VectorXd &y_train, double y_dot_alpha) const override
StudentTProcessRegression()
double log_det_cholesky(const EigenMatrix &L)
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Eigen::Matrix< double, EigenDynamic, EigenDynamic, EigenMatrixStorage > EigenMatrix
Observation data: energy, gradient and positions.