40 if (!(robust_nu_ > 0.0) || !lik_gaussian)
return false;
41 const Eigen::Index n_geom = full_observation.
R.rows();
42 const Eigen::Index dim = full_observation.
R.cols();
46 const Eigen::Index n =
R_matrix.rows();
54 if (K.rows() != n || K.cols() != n || !K.allFinite())
return false;
55 if (jitter_sigma2 > 0.0) K.diagonal().array() += jitter_sigma2;
56 applyKernelNugget(K, n);
57 Eigen::LLT<EigenMatrix> llt(K);
58 if (llt.info() != Eigen::Success)
return false;
61 if (!alpha.allFinite())
return false;
63 const double sigma2 = lik_gaussian->getSigma2();
64 Eigen::VectorXd z2 = Eigen::VectorXd::Zero(n_geom);
65 Eigen::VectorXd extra = Eigen::VectorXd::Zero(n_geom);
66 Eigen::VectorXd channels = Eigen::VectorXd::Zero(n_geom);
67 std::vector<Eigen::Index> rows;
68 for (Eigen::Index g = 0; g < n_geom; ++g) {
70 for (Eigen::Index i = 0; i < n; ++i) {
71 if ((
R_matrix.row(i).head(dim).array() ==
72 full_observation.
R.row(g).array())
76 const Eigen::Index d =
static_cast<Eigen::Index
>(rows.size());
78 channels(g) =
static_cast<double>(d);
81 Eigen::VectorXd alpha_B(d);
82 for (Eigen::Index k = 0; k < d; ++k) {
83 E(rows[
static_cast<std::size_t
>(k)], k) = 1.0;
84 alpha_B(k) = alpha(rows[
static_cast<std::size_t
>(k)]);
87 L_dense.template triangularView<Eigen::Lower>().solve(E);
89 Eigen::LLT<EigenMatrix> block(Kinv_BB);
90 if (block.info() != Eigen::Success)
continue;
91 const double norm = alpha_B.dot(block.solve(alpha_B));
92 if (!std::isfinite(norm) || norm < 0.0)
continue;
94 extra(g) = std::max(0.0, sigma2 * (norm -
static_cast<double>(d)) /
95 (robust_nu_ +
static_cast<double>(d)));
97 const Eigen::VectorXd& previous = lik_gaussian->geometryExtraNoise();
98 const bool changed = previous.size() != n_geom ||
99 (previous - extra).cwiseAbs().maxCoeff() >
100 std::numeric_limits<double>::epsilon() *
101 (1.0 + extra.cwiseAbs().maxCoeff());
103 robust_extra_ = extra;
104 lik_gaussian->setGeometryExtraNoise(full_observation.
R, extra);
105 if (report_level >= 1) {
106 Eigen::Index downweighted = 0;
107 for (Eigen::Index g = 0; g < n_geom; ++g)
108 if (extra(g) > 0.0) ++downweighted;
109 Eigen::Index worst = 0;
111 log_man <<
"Robust rows: nu=" << robust_nu_ <<
", " << downweighted
113 <<
" configurations above their expected "
114 "leave-one-geometry-out misfit; worst z2="
115 << z2(worst) <<
" over " << channels(worst)
116 <<
" channels (weight "
117 << (robust_nu_ + channels(worst)) / (robust_nu_ + z2(worst))
118 <<
", extra noise " << extra(worst) <<
")\n";
void evaluateTrainingCovarianceMatrix(const EigenMatrix &x, const Eigen::VectorXd &x_ind, EigenMatrix &cov_matrix, bool serial_per_rank=false, bool include_constant=true, bool include_noise=true)
Evaluate training covariance matrix (gp_cov + noise covariance).