diff --git a/src/stan/mcmc/chainset.hpp b/src/stan/mcmc/chainset.hpp index 8ff5644693..68256b6c0d 100644 --- a/src/stan/mcmc/chainset.hpp +++ b/src/stan/mcmc/chainset.hpp @@ -253,7 +253,7 @@ class chainset { double median(const std::string& name) const { return median(index(name)); } /** - * Compute maximum absolute deviation (mad) for specified parameter. + * Compute median absolute deviation (mad) for specified parameter. * * Follows R implementation: constant * median(abs(x - center)) * where the value of center is median(x) and the constant is 1.4826, @@ -263,7 +263,7 @@ class chainset { * @param index parameter index * @return sample mad */ - double max_abs_deviation(const int index) const { + double med_abs_deviation(const int index) const { Eigen::MatrixXd draws = samples(index); auto center = median(index); Eigen::MatrixXd abs_dev = (draws.array() - center).abs(); @@ -272,7 +272,7 @@ class chainset { } /** - * Compute maximum absolute deviation (mad) for specified parameter. + * Compute median absolute deviation (mad) for specified parameter. * * Follows R implementation: constant * median(abs(x - center)) * where the value of center is median(x) and the constant is 1.4826, @@ -282,8 +282,8 @@ class chainset { * @param name parameter name * @return sample mad */ - double max_abs_deviation(const std::string& name) const { - return max_abs_deviation(index(name)); + double med_abs_deviation(const std::string& name) const { + return med_abs_deviation(index(name)); } /** diff --git a/src/test/unit/mcmc/chainset_test.cpp b/src/test/unit/mcmc/chainset_test.cpp index 10cc03fe95..b7ed38baa0 100644 --- a/src/test/unit/mcmc/chainset_test.cpp +++ b/src/test/unit/mcmc/chainset_test.cpp @@ -170,7 +170,7 @@ TEST_F(McmcChains, summary_stats) { EXPECT_NEAR(theta_sd_expect, bern_chains.sd("theta"), 1e-5); double theta_mad_expect = 0.12309; - EXPECT_NEAR(theta_mad_expect, bern_chains.max_abs_deviation("theta"), 1e-5); + EXPECT_NEAR(theta_mad_expect, bern_chains.med_abs_deviation("theta"), 1e-5); double theta_mcse_mean_expect = 0.003234; EXPECT_NEAR(theta_mcse_mean_expect, bern_chains.mcse_mean("theta"), 1e-4);