diff --git a/src/stan/analyze/mcmc/compute_potential_scale_reduction.hpp b/src/stan/analyze/mcmc/compute_potential_scale_reduction.hpp index b187cb14c7..47d0769573 100644 --- a/src/stan/analyze/mcmc/compute_potential_scale_reduction.hpp +++ b/src/stan/analyze/mcmc/compute_potential_scale_reduction.hpp @@ -184,7 +184,7 @@ inline std::pair compute_potential_scale_reduction_rank( */ inline double compute_potential_scale_reduction( const std::vector& draws, const std::vector& sizes) { - return compute_potential_scale_reduction_rank(draws, sizes).first; + return compute_potential_scale_reduction_rank(draws, sizes).first; } /** diff --git a/src/stan/mcmc/chains.hpp b/src/stan/mcmc/chains.hpp index 1e763d0414..69ae7669f8 100644 --- a/src/stan/mcmc/chains.hpp +++ b/src/stan/mcmc/chains.hpp @@ -623,7 +623,8 @@ class chains { sizes[chain] = n_kept_samples; } - return analyze::compute_split_potential_scale_reduction_rank(draws, sizes).first; + return analyze::compute_split_potential_scale_reduction_rank(draws, sizes) + .first; } std::pair split_potential_scale_reduction_rank( diff --git a/src/test/unit/analyze/mcmc/compute_potential_scale_reduction_test.cpp b/src/test/unit/analyze/mcmc/compute_potential_scale_reduction_test.cpp index 2d7d25afc6..84f6efbe81 100644 --- a/src/test/unit/analyze/mcmc/compute_potential_scale_reduction_test.cpp +++ b/src/test/unit/analyze/mcmc/compute_potential_scale_reduction_test.cpp @@ -31,7 +31,13 @@ TEST_F(ComputeRhat, compute_potential_scale_reduction) { chains.add(blocker2); Eigen::VectorXd rhat(48); - rhat << 1.00067, 0.999789, 0.999656, 1.00055, 1.0011, 1.00088, 1.00032, 0.999969, 1.00201, 0.999558, 0.999555, 0.9995, 1.00292, 1.00516, 1.00591, 0.999753, 1.00088, 1.00895, 1.00079, 0.99953, 1.00092, 1.00044, 1.01005, 0.999598, 1.00151, 0.999659, 0.999648, 0.999627, 1.00315, 1.00277, 1.00247, 1.00003, 0.999937, 1.00116, 0.999521, 1.0005, 1.00091, 1.00213, 1.00019, 0.999767, 1.0003, 0.999815, 1.00003, 0.999672, 1.00306, 1.00072, 0.999602, 0.999789; + rhat << 1.00067, 0.999789, 0.999656, 1.00055, 1.0011, 1.00088, 1.00032, + 0.999969, 1.00201, 0.999558, 0.999555, 0.9995, 1.00292, 1.00516, 1.00591, + 0.999753, 1.00088, 1.00895, 1.00079, 0.99953, 1.00092, 1.00044, 1.01005, + 0.999598, 1.00151, 0.999659, 0.999648, 0.999627, 1.00315, 1.00277, + 1.00247, 1.00003, 0.999937, 1.00116, 0.999521, 1.0005, 1.00091, 1.00213, + 1.00019, 0.999767, 1.0003, 0.999815, 1.00003, 0.999672, 1.00306, 1.00072, + 0.999602, 0.999789; // replicates calls to stan::analyze::compute_effective_sample_size // for any interface *without* access to chains class @@ -46,7 +52,8 @@ TEST_F(ComputeRhat, compute_potential_scale_reduction) { sizes[chain] = samples(chain).size(); } ASSERT_NEAR(rhat(index - 4), - stan::analyze::compute_potential_scale_reduction(draws, sizes), 1e-4) + stan::analyze::compute_potential_scale_reduction(draws, sizes), + 1e-4) << "rhat for index: " << index << ", parameter: " << chains.param_name(index); } @@ -122,7 +129,13 @@ TEST_F(ComputeRhat, compute_potential_scale_reduction_convenience) { chains.add(blocker2); Eigen::VectorXd rhat(48); - rhat << 1.00067, 0.999789, 0.999656, 1.00055, 1.0011, 1.00088, 1.00032, 0.999969, 1.00201, 0.999558, 0.999555, 0.9995, 1.00292, 1.00516, 1.00591, 0.999753, 1.00088, 1.00895, 1.00079, 0.99953, 1.00092, 1.00044, 1.01005, 0.999598, 1.00151, 0.999659, 0.999648, 0.999627, 1.00315, 1.00277, 1.00247, 1.00003, 0.999937, 1.00116, 0.999521, 1.0005, 1.00091, 1.00213, 1.00019, 0.999767, 1.0003, 0.999815, 1.00003, 0.999672, 1.00306, 1.00072, 0.999602, 0.999789; + rhat << 1.00067, 0.999789, 0.999656, 1.00055, 1.0011, 1.00088, 1.00032, + 0.999969, 1.00201, 0.999558, 0.999555, 0.9995, 1.00292, 1.00516, 1.00591, + 0.999753, 1.00088, 1.00895, 1.00079, 0.99953, 1.00092, 1.00044, 1.01005, + 0.999598, 1.00151, 0.999659, 0.999648, 0.999627, 1.00315, 1.00277, + 1.00247, 1.00003, 0.999937, 1.00116, 0.999521, 1.0005, 1.00091, 1.00213, + 1.00019, 0.999767, 1.0003, 0.999815, 1.00003, 0.999672, 1.00306, 1.00072, + 0.999602, 0.999789; Eigen::Matrix samples( chains.num_chains()); @@ -209,7 +222,12 @@ TEST_F(ComputeRhat, chains_compute_split_potential_scale_reduction) { chains.add(blocker2); Eigen::VectorXd rhat(48); - rhat << 1.0078, 1.0109, 0.999187, 1.001, 1.00401, 1.00992, 1.00182, 1.00519, 1.00095, 1.00351, 1.00554, 1.00075, 1.00595, 1.00473, 1.00546, 1.01304, 1.00166, 1.0074, 1.00178, 1.00588, 1.00406, 1.00129, 1.00976, 1.0013, 1.00193, 1.00104, 0.999383, 1.00025, 1.01082, 1.0019, 1.00354, 1.0043, 1.00111, 1.00281, 1.00436, 1.00515, 1.00325, 1.0089, 1.00222, 1.00118, 1.00191, 1.00283, 1.0003, 1.00216, 1.00335, 1.00133, 1.00023, 1.0109; + rhat << 1.0078, 1.0109, 0.999187, 1.001, 1.00401, 1.00992, 1.00182, 1.00519, + 1.00095, 1.00351, 1.00554, 1.00075, 1.00595, 1.00473, 1.00546, 1.01304, + 1.00166, 1.0074, 1.00178, 1.00588, 1.00406, 1.00129, 1.00976, 1.0013, + 1.00193, 1.00104, 0.999383, 1.00025, 1.01082, 1.0019, 1.00354, 1.0043, + 1.00111, 1.00281, 1.00436, 1.00515, 1.00325, 1.0089, 1.00222, 1.00118, + 1.00191, 1.00283, 1.0003, 1.00216, 1.00335, 1.00133, 1.00023, 1.0109; for (int index = 4; index < chains.num_params(); index++) { ASSERT_NEAR(rhat(index - 4), chains.split_potential_scale_reduction(index), 1e-4) @@ -286,7 +304,12 @@ TEST_F(ComputeRhat, compute_split_potential_scale_reduction) { chains.add(blocker2); Eigen::VectorXd rhat(48); - rhat << 1.0078, 1.0109, 0.999187, 1.001, 1.00401, 1.00992, 1.00182, 1.00519, 1.00095, 1.00351, 1.00554, 1.00075, 1.00595, 1.00473, 1.00546, 1.01304, 1.00166, 1.0074, 1.00178, 1.00588, 1.00406, 1.00129, 1.00976, 1.0013, 1.00193, 1.00104, 0.999383, 1.00025, 1.01082, 1.0019, 1.00354, 1.0043, 1.00111, 1.00281, 1.00436, 1.00515, 1.00325, 1.0089, 1.00222, 1.00118, 1.00191, 1.00283, 1.0003, 1.00216, 1.00335, 1.00133, 1.00023, 1.0109; + rhat << 1.0078, 1.0109, 0.999187, 1.001, 1.00401, 1.00992, 1.00182, 1.00519, + 1.00095, 1.00351, 1.00554, 1.00075, 1.00595, 1.00473, 1.00546, 1.01304, + 1.00166, 1.0074, 1.00178, 1.00588, 1.00406, 1.00129, 1.00976, 1.0013, + 1.00193, 1.00104, 0.999383, 1.00025, 1.01082, 1.0019, 1.00354, 1.0043, + 1.00111, 1.00281, 1.00436, 1.00515, 1.00325, 1.0089, 1.00222, 1.00118, + 1.00191, 1.00283, 1.0003, 1.00216, 1.00335, 1.00133, 1.00023, 1.0109; // replicates calls to stan::analyze::compute_effective_sample_size // for any interface *without* access to chains class @@ -379,7 +402,12 @@ TEST_F(ComputeRhat, compute_split_potential_scale_reduction_convenience) { chains.add(blocker2); Eigen::VectorXd rhat(48); - rhat << 1.0078, 1.0109, 0.999187, 1.001, 1.00401, 1.00992, 1.00182, 1.00519, 1.00095, 1.00351, 1.00554, 1.00075, 1.00595, 1.00473, 1.00546, 1.01304, 1.00166, 1.0074, 1.00178, 1.00588, 1.00406, 1.00129, 1.00976, 1.0013, 1.00193, 1.00104, 0.999383, 1.00025, 1.01082, 1.0019, 1.00354, 1.0043, 1.00111, 1.00281, 1.00436, 1.00515, 1.00325, 1.0089, 1.00222, 1.00118, 1.00191, 1.00283, 1.0003, 1.00216, 1.00335, 1.00133, 1.00023, 1.0109; + rhat << 1.0078, 1.0109, 0.999187, 1.001, 1.00401, 1.00992, 1.00182, 1.00519, + 1.00095, 1.00351, 1.00554, 1.00075, 1.00595, 1.00473, 1.00546, 1.01304, + 1.00166, 1.0074, 1.00178, 1.00588, 1.00406, 1.00129, 1.00976, 1.0013, + 1.00193, 1.00104, 0.999383, 1.00025, 1.01082, 1.0019, 1.00354, 1.0043, + 1.00111, 1.00281, 1.00436, 1.00515, 1.00325, 1.0089, 1.00222, 1.00118, + 1.00191, 1.00283, 1.0003, 1.00216, 1.00335, 1.00133, 1.00023, 1.0109; Eigen::Matrix samples( chains.num_chains()); @@ -397,7 +425,6 @@ TEST_F(ComputeRhat, compute_split_potential_scale_reduction_convenience) { 1e-4) << "rhat for index: " << index << ", parameter: " << chains.param_name(index); - } } diff --git a/src/test/unit/mcmc/chains_test.cpp b/src/test/unit/mcmc/chains_test.cpp index 7bf581ab31..b0d0db1d24 100644 --- a/src/test/unit/mcmc/chains_test.cpp +++ b/src/test/unit/mcmc/chains_test.cpp @@ -853,13 +853,12 @@ TEST_F(McmcChains, blocker_split_potential_scale_reduction) { chains.add(blocker2); Eigen::VectorXd rhat(48); - rhat << 1.0078, 1.0109, 0.99919, 1.001, 1.00401, 1.00992, 1.00182, - 1.00519, 1.00095, 1.00351, 1.00554, 1.00075, 1.00595, 1.00473, 1.00546, - 1.01304, 1.00166, 1.0074, 1.00178, 1.00588, 1.00406, 1.00129, 1.00976, - 1.0013, 1.00193, 1.00104, 0.99938, 1.00025, 1.01082, 1.0019, 1.00354, - 1.0043, 1.00111, 1.00281, 1.00436, 1.00515, 1.00325, 1.0089, 1.00222, - 1.00118, 1.00191, 1.00283, 1.0003, 1.00216, 1.00335, 1.00133, 1.00023, - 1.0109; + rhat << 1.0078, 1.0109, 0.99919, 1.001, 1.00401, 1.00992, 1.00182, 1.00519, + 1.00095, 1.00351, 1.00554, 1.00075, 1.00595, 1.00473, 1.00546, 1.01304, + 1.00166, 1.0074, 1.00178, 1.00588, 1.00406, 1.00129, 1.00976, 1.0013, + 1.00193, 1.00104, 0.99938, 1.00025, 1.01082, 1.0019, 1.00354, 1.0043, + 1.00111, 1.00281, 1.00436, 1.00515, 1.00325, 1.0089, 1.00222, 1.00118, + 1.00191, 1.00283, 1.0003, 1.00216, 1.00335, 1.00133, 1.00023, 1.0109; for (int index = 4; index < chains.num_params(); index++) { ASSERT_NEAR(rhat(index - 4), chains.split_potential_scale_reduction(index),