From 21b8a57fad73801b91088d49e9c8901cfc99df05 Mon Sep 17 00:00:00 2001 From: Young Geun Kim Date: Sun, 8 Sep 2024 13:48:22 +0900 Subject: [PATCH] fix gig domain --- inst/include/bvharsim.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/inst/include/bvharsim.h b/inst/include/bvharsim.h index d38b79f1..146788c0 100644 --- a/inst/include/bvharsim.h +++ b/inst/include/bvharsim.h @@ -451,12 +451,13 @@ inline Eigen::VectorXd sim_gig(int num_sim, double lambda, double psi, double ch for (int i = 0; i < num_sim; ++i) { res[i] = gamma_rand(abs_lam, 2 / psi); // GIG(shape, 2 * rate, 0) <=> Gamma(shape, rate) } - } else { + return res; + } else if (lambda < 0) { for (int i = 0; i < num_sim; ++i) { res[i] = 1 / gamma_rand(abs_lam, 2 / chi); // GIG(-shape, 0, 2 * scale) <=> Inverse-Gamma(shape, scale) } + return res; } - return res; } // if (chi < 15 * std::numeric_limits::epsilon()) { // for (int i = 0; i < num_sim; ++i) { @@ -505,12 +506,13 @@ inline Eigen::VectorXd sim_gig(int num_sim, double lambda, double psi, double ch for (int i = 0; i < num_sim; ++i) { res[i] = gamma_rand(abs_lam, 2 / psi, rng); // GIG(shape, 2 * rate, 0) <=> Gamma(shape, rate) } - } else { + return res; + } else if (lambda < 0) { for (int i = 0; i < num_sim; ++i) { res[i] = 1 / gamma_rand(abs_lam, 2 / chi, rng); // GIG(-shape, 0, 2 * scale) } + return res; } - return res; } // if (chi < 8 * std::numeric_limits::epsilon()) { // for (int i = 0; i < num_sim; ++i) {