src/algorithms/neal8_algorithm.cc
//! \param temp_hier Temporary hierarchy object
//! \return          Vector of evaluation of component on the provided grid
\param temp_hier Temporary hierarchy object
\return          Vector of evaluation of component on the provided grid
\ param temp_hier Temporary hierarchy object \ return Vector of evaluation of component on the provided grid
Eigen::VectorXd Neal8Algorithm::lpdf_marginal_component(
    std::shared_ptr<BaseHierarchy> temp_hier, const Eigen::MatrixXd &grid) {
  unsigned int n_grid = grid.rows();
  Eigen::VectorXd lpdf_(n_grid);
  Eigen::MatrixXd lpdf_temp(n_grid, n_aux);
  for (size_t i = 0; i < n_aux; i++) {
    temp_hier->draw();
    lpdf_temp.col(i) = temp_hier->like_lpdf_grid(grid);
  }
  for (size_t i = 0; i < n_grid; i++) {
    lpdf_(i) = stan::math::log_sum_exp(lpdf_temp.row(i));
  }
  return lpdf_.array() - log(n_aux);
}
Eigen :: VectorXd Neal8Algorithm :: lpdf_marginal_component ( std :: shared_ptr < BaseHierarchy > temp_hier , const Eigen :: MatrixXd & grid ) { unsigned int n_grid = grid . rows ( ) ; Eigen :: VectorXd lpdf_ ( n_grid ) ; Eigen :: MatrixXd lpdf_temp ( n_grid , n_aux ) ; for ( size_t i = 0 ; i < n_aux ; i ++ ) { temp_hier -> draw ( ) ; lpdf_temp . col ( i ) = temp_hier -> like_lpdf_grid ( grid ) ; } for ( size_t i = 0 ; i < n_grid ; i ++ ) { lpdf_ ( i ) = stan :: math :: log_sum_exp ( lpdf_temp . row ( i ) ) ; } return lpdf_ . array ( ) - log ( n_aux ) ; }
\param temp_hier Temporary hierarchy object
\return          Vector of evaluation of component on the provided grid
\ param temp_hier Temporary hierarchy object \ return Vector of evaluation of component on the provided grid
// Loop over unique values for a "sample mean" of the marginal // Generate unique values from their prior centering distribution