Skip to content

Commit

Permalink
changes per code review
Browse files Browse the repository at this point in the history
  • Loading branch information
mitzimorris committed Oct 21, 2024
1 parent 32b7fec commit b4febe8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
9 changes: 5 additions & 4 deletions src/test/unit/analyze/mcmc/ess_basic_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class EssBasic : public testing::Test {
};

TEST_F(EssBasic, test_basic_ess) {
// computed via R pkg posterior
double ess_lp_expect = 1335.4137;
double ess_theta_expect = 1377.503;

Expand All @@ -53,9 +54,9 @@ TEST_F(EssBasic, test_basic_ess) {
auto old_ess_basic_theta
= stan::analyze::compute_effective_sample_size(draws_theta, sizes);

EXPECT_NEAR(ess_lp_expect, ess_basic_lp, 0.0001);
EXPECT_NEAR(ess_theta_expect, ess_basic_theta, 0.0001);
EXPECT_NEAR(ess_lp_expect, ess_basic_lp, 1e-4);
EXPECT_NEAR(ess_theta_expect, ess_basic_theta, 1e-4);

EXPECT_NEAR(old_ess_basic_lp, ess_basic_lp, 0.00001);
EXPECT_NEAR(old_ess_basic_theta, ess_basic_theta, 0.00001);
EXPECT_NEAR(old_ess_basic_lp, ess_basic_lp, 1e-9);
EXPECT_NEAR(old_ess_basic_theta, ess_basic_theta, 1e-9);
}
17 changes: 9 additions & 8 deletions src/test/unit/analyze/mcmc/mcse_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,19 @@ class MonteCarloStandardError : public testing::Test {
};

TEST_F(MonteCarloStandardError, test_mcse) {
double mcse_mean_lp_expect = 0.020164778;
double mcse_mean_theta_expect = 0.0032339916;
// computed via R pkg posterior
double mcse_mean_lp_expect = 0.02016;
double mcse_mean_theta_expect = 0.00323;

double mcse_sd_lp_expect = 0.0355305;
double mcse_sd_theta_expect = 0.0021642137;
EXPECT_NEAR(mcse_mean_lp_expect, stan::analyze::mcse_mean(chains_lp), 0.0001);
double mcse_sd_lp_expect = 0.03553;
double mcse_sd_theta_expect = 0.00216;
EXPECT_NEAR(mcse_mean_lp_expect, stan::analyze::mcse_mean(chains_lp), 1e-4);
EXPECT_NEAR(mcse_mean_theta_expect, stan::analyze::mcse_mean(chains_theta),
0.0001);
1e-4);

EXPECT_NEAR(mcse_sd_lp_expect, stan::analyze::mcse_sd(chains_lp), 0.0001);
EXPECT_NEAR(mcse_sd_lp_expect, stan::analyze::mcse_sd(chains_lp), 1e-4);
EXPECT_NEAR(mcse_sd_theta_expect, stan::analyze::mcse_sd(chains_theta),
0.0001);
1e-4);
}

TEST_F(MonteCarloStandardError, const_fail) {
Expand Down
9 changes: 5 additions & 4 deletions src/test/unit/analyze/mcmc/rhat_basic_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class RhatBasic : public testing::Test {
};

TEST_F(RhatBasic, test_basic_rhat) {
// computed via R pkg posterior
double rhat_lp_basic_expect = 1.0001296;
double rhat_theta_basic_expect = 1.0029197;

Expand All @@ -51,9 +52,9 @@ TEST_F(RhatBasic, test_basic_rhat) {
auto old_rhat_basic_theta
= stan::analyze::compute_potential_scale_reduction(draws_theta, sizes);

EXPECT_NEAR(rhat_lp_basic_expect, rhat_basic_lp, 0.00001);
EXPECT_NEAR(rhat_theta_basic_expect, rhat_basic_theta, 0.00001);
EXPECT_NEAR(rhat_lp_basic_expect, rhat_basic_lp, 1e-5);
EXPECT_NEAR(rhat_theta_basic_expect, rhat_basic_theta, 1e-5);

EXPECT_NEAR(old_rhat_basic_lp, rhat_basic_lp, 0.00001);
EXPECT_NEAR(old_rhat_basic_theta, rhat_basic_theta, 0.00001);
EXPECT_NEAR(old_rhat_basic_lp, rhat_basic_lp, 1e-9);
EXPECT_NEAR(old_rhat_basic_theta, rhat_basic_theta, 1e-9);
}

0 comments on commit b4febe8

Please sign in to comment.