MaCh3  2.5.1
Reference Guide
Functions
PredictiveThrower.cpp File Reference
#include "PredictiveThrower.h"
#include "Parameters/ParameterHandlerGeneric.h"
#include "TH3.h"
Include dependency graph for PredictiveThrower.cpp:

Go to the source code of this file.

Functions

bool CheckBounds (const std::vector< const M3::float_t * > &BoundValuePointer, const std::vector< std::pair< double, double >> &ParamBounds)
 
void AccumulateWAICToy (const double neg_LLH_temp, double &mean_llh, double &mean_llh_squared, double &sum_exp_llh)
 
void AccumulateWAICBin (double &mean_llh, double &mean_llh_squared, double &sum_exp_llh, const unsigned int Ntoys, double &lppd, double &p_WAIC)
 

Function Documentation

◆ AccumulateWAICBin()

void AccumulateWAICBin ( double &  mean_llh,
double &  mean_llh_squared,
double &  sum_exp_llh,
const unsigned int  Ntoys,
double &  lppd,
double &  p_WAIC 
)

Definition at line 1895 of file PredictiveThrower.cpp.

1896  {
1897 // ****************
1898  // Compute the mean log-likelihood and the squared mean
1899  mean_llh /= Ntoys;
1900  mean_llh_squared /= Ntoys;
1901  sum_exp_llh /= Ntoys;
1902  sum_exp_llh = std::log(sum_exp_llh);
1903 
1904  // Log pointwise predictive density based on Eq. 4 in Gelman2014
1905  lppd += sum_exp_llh;
1906 
1907  // Compute the effective number of parameters for WAIC
1908  p_WAIC += mean_llh_squared - (mean_llh * mean_llh);
1909 }
int Ntoys

◆ AccumulateWAICToy()

void AccumulateWAICToy ( const double  neg_LLH_temp,
double &  mean_llh,
double &  mean_llh_squared,
double &  sum_exp_llh 
)

Definition at line 1880 of file PredictiveThrower.cpp.

1883  {
1884 // ****************
1885  // Negate the negative log-likelihood to get the actual log-likelihood
1886  double LLH_temp = -neg_LLH_temp;
1887 
1888  mean_llh += LLH_temp;
1889  mean_llh_squared += LLH_temp * LLH_temp;
1890  sum_exp_llh += std::exp(LLH_temp);
1891 }

◆ CheckBounds()

bool CheckBounds ( const std::vector< const M3::float_t * > &  BoundValuePointer,
const std::vector< std::pair< double, double >> &  ParamBounds 
)

Definition at line 454 of file PredictiveThrower.cpp.

455  {
456 // *************************
457  for (size_t i = 0; i < BoundValuePointer.size(); ++i) {
458  const double val = *(BoundValuePointer[i]);
459  const double minVal = ParamBounds[i].first;
460  const double maxVal = ParamBounds[i].second;
461 
462  if (val < minVal || val > maxVal)
463  return false; // out of bounds
464  }
465  return true; // all values are within bounds
466 }