53double calcChi2_volume(
const Eigen::MatrixBase<DerivedD>& D,
const Eigen::Index& ncand = 2,
double factor = 1.5)
55 auto n =
static_cast<double>(D.rows());
58 double Vn = 2.0 * std::pow(M_PI, n / 2.0) / (n * std::tgamma(n / 2.0));
61 for (Eigen::Index i = 1; i < D.rows(); i++) { detQ *= D(i); }
63 return factor * std::pow(
static_cast<double>(ncand) / (std::sqrt(detQ * Vn)), 2.0 / n);
80double calcChi2_bootstrap(
const Eigen::MatrixBase<DerivedA>& a,
const Eigen::MatrixBase<DerivedQ>& Q,
81 const Eigen::MatrixBase<DerivedL>& L_LTDL_Q,
const Eigen::Index& ncand = 2)
83 typename DerivedL::PlainObject Qz_inv = Q.inverse();
85 std::vector<double> chi(
static_cast<size_t>(a.rows()) + 1);
86 for (Eigen::Index k = a.rows(); k >= 0; k--)
88 typename DerivedA::PlainObject a_fix = a;
89 typename DerivedA::PlainObject a_float = a;
91 for (Eigen::Index i = a.rows() - 1; i >= 0; i--)
94 for (Eigen::Index j = a.rows() - 1; j >= i; j--)
96 da += L_LTDL_Q(j, i) * (a_float(j) - a_fix(j));
102 a_fix(i) = std::round(a_float(i));
106 auto nearest = std::round(a_float(i));
107 a_fix(i) = nearest + gcem::sgn(a_float(i) - nearest);
111 chi.at(
static_cast<size_t>(k)) = (a - a_fix).transpose() * Qz_inv * (a - a_fix);
113 std::ranges::sort(chi);
115 return chi.at(
static_cast<size_t>(ncand - 1)) + 1e-6;
129double calcChi2(
const Eigen::MatrixBase<DerivedA>& a,
const Eigen::MatrixBase<DerivedQ>& Q,
130 const Eigen::MatrixBase<DerivedL>& L_LTDL_Q,
const Eigen::MatrixBase<DerivedD>& D_LTDL_Q,
131 const Eigen::Index& ncand = 2,
double factor = 1.5)
133 if (ncand <= a.rows() + 1)
double calcChi2_volume(const Eigen::MatrixBase< DerivedD > &D, const Eigen::Index &ncand=2, double factor=1.5)
Calculates , the size of the ellipsoidal region, via volume of the ellipsoidal region.
double calcChi2_bootstrap(const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedQ > &Q, const Eigen::MatrixBase< DerivedL > &L_LTDL_Q, const Eigen::Index &ncand=2)
Calculates , the size of the ellipsoidal region, via bootrapping.
double calcChi2(const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedQ > &Q, const Eigen::MatrixBase< DerivedL > &L_LTDL_Q, const Eigen::MatrixBase< DerivedD > &D_LTDL_Q, const Eigen::Index &ncand=2, double factor=1.5)
Calculates , the size of the ellipsoidal region.