23 m_parser = std::make_unique<MaCh3ArgumentParser>(
"rhat",
"1.0", argparse::default_arguments::help);
24 m_parser->add_description(
"Tool for computing the R-hat diagnostic for MCMC chains.");
26 .help(
"if in high mem mode this is number of toys per chain, for low mem thinning setting")
31 .help(
"Enable high memory mode.")
34 .help(
"MCMC chain root files")
35 .metavar(
"MCMC_CHAIN1 [MCMC_CHAIN2 [...]]")
36 .nargs(argparse::nargs_pattern::at_least_one)
45 std::vector<std::string> MCMCFile;
46 auto mcmc_chain_args =
m_parser->get<std::vector<std::string>>(
"mcmc-chain");
48 if (mcmc_chain_args.empty()){
50 MACH3LOG_ERROR(
"./RHat NThin MCMCchain_1.root MCMCchain_2.root MCMCchain_3.root ... [how many you like]");
54 int NThinToys =
m_parser->get<
int>(
"n-thin");
55 std::size_t Nchains = mcmc_chain_args.size();
58 for (
const auto& file : mcmc_chain_args){
63 MACH3LOG_WARN(
"Gelman is going to be sad :(. He suggested you should use more than one chain (at least 4). Code works fine for one chain, however, estimator might be biased.");
64 MACH3LOG_WARN(
"Multiple chains are more likely to reveal multimodality and poor adaptation or mixing:");
69 bool high_mem =
m_parser->get<
bool>(
"--high-mem");
73 MACH3LOG_ERROR(
"You specified {} for NToys, specify larger greater than 0", NThinToys);
78 auto RHatCalc = std::make_unique<RHatCalculator>(high_mem, mcmc_chain_args, NThinToys);
79 RHatCalc->RunDiagnostic();
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Module for computing the R-hat diagnostic for MCMC chains.
Extended ArgumentParser with MaCh3-specific functionality.
std::unique_ptr< MaCh3ArgumentParser > m_parser
Argument parser for this plugin.
int Run() override
Execute the MCMC diagnostics.
MaCh3ArgumentParser * get_parser() override
Get the argument parser for this module.
virtual ~RHatModule()
Destructor.
Custom exception class used throughout MaCh3.
void MaCh3Welcome()
KS: Prints welcome message with MaCh3 logo.
Main namespace for MaCh3 software.