src/hierarchies/nnig_hierarchy.cc
//! \param data                        Column vector of data points
//! \param mu0, alpha0, beta0, lambda0 Original values for hyperparameters
//! \return                            Vector of updated values for hyperpar.s
\param data                        Column vector of data points
\param mu0, alpha0, beta0, lambda0 Original values for hyperparameters
\return                            Vector of updated values for hyperpar.s
\ param data Column vector of data points \ param mu0 alpha0 beta0 lambda0 Original values for hyperparameters \ return Vector of updated values for hyperpar . s
NNIGHierarchy::Hyperparams NNIGHierarchy::normal_invgamma_update() {
  Hyperparams post_params;
  if (card == 0) {  
    post_params = *hypers;
    return post_params;
  }
  double y_bar = data_sum / (1.0 * card);  
  double ss = data_sum_squares - card * y_bar * y_bar;
  post_params.mean = (hypers->var_scaling * hypers->mean + data_sum) /
                     (hypers->var_scaling + card);
  post_params.var_scaling = hypers->var_scaling + card;
  post_params.shape = hypers->shape + 0.5 * card;
  post_params.scale = hypers->scale + 0.5 * ss +
                      0.5 * hypers->var_scaling * card *
                          (y_bar - hypers->mean) * (y_bar - hypers->mean) /
                          (card + hypers->var_scaling);
  return post_params;
}
NNIGHierarchy :: Hyperparams NNIGHierarchy :: normal_invgamma_update ( ) { Hyperparams post_params ; if ( card == 0 ) { post_params = * hypers ; return post_params ; } double y_bar = data_sum / ( 1.0 * card ) ; double ss = data_sum_squares - card * y_bar * y_bar ; post_params . mean = ( hypers -> var_scaling * hypers -> mean + data_sum ) / ( hypers -> var_scaling + card ) ; post_params . var_scaling = hypers -> var_scaling + card ; post_params . shape = hypers -> shape + 0.5 * card ; post_params . scale = hypers -> scale + 0.5 * ss + 0.5 * hypers -> var_scaling * card * ( y_bar - hypers -> mean ) * ( y_bar - hypers -> mean ) / ( card + hypers -> var_scaling ) ; return post_params ; }
\param data                        Column vector of data points
\param mu0, alpha0, beta0, lambda0 Original values for hyperparameters
\return                            Vector of updated values for hyperpar.s
\ param data Column vector of data points \ param mu0 alpha0 beta0 lambda0 Original values for hyperparameters \ return Vector of updated values for hyperpar . s
// Initialize relevant variables // no update possible // Compute updated hyperparameters // sample mean