@@ -218,12 +218,13 @@ double LogLinearVarianceLeafModel::NoSplitLogMarginalLikelihood(LogLinearVarianc
218
218
}
219
219
220
220
double LogLinearVarianceLeafModel::SuffStatLogMarginalLikelihood (LogLinearVarianceSuffStat& suff_stat, double global_variance) {
221
+ double prior_terms = a_ * std::log (b_) - boost::math::lgamma (a_);
221
222
double a_term = a_ + 0.5 * suff_stat.n ;
222
223
double b_term = b_ + ((0.5 * suff_stat.weighted_sum_ei ) / global_variance);
223
224
double log_b_term = std::log (b_term);
224
225
double lgamma_a_term = boost::math::lgamma (a_term);
225
226
double resid_term = a_term * log_b_term;
226
- double log_ml = lgamma_a_term - resid_term;
227
+ double log_ml = prior_terms + lgamma_a_term - resid_term;
227
228
return log_ml;
228
229
}
229
230
@@ -258,7 +259,9 @@ void LogLinearVarianceLeafModel::SampleLeafParameters(ForestDataset& dataset, Fo
258
259
node_rate = PosteriorParameterRate (node_suff_stat, global_variance);
259
260
260
261
// Draw from IG(shape, scale) and set the leaf parameter with each draw
261
- node_mu = std::log (gamma_sampler_.Sample (node_shape, node_rate, gen, true ));
262
+ std::gamma_distribution<double > gamma_dist_ (node_shape, 1 .);
263
+ node_mu = std::log (gamma_dist_ (gen) / node_rate);
264
+ // node_mu = std::log(gamma_sampler_.Sample(node_shape, node_rate, gen, true));
262
265
tree->SetLeaf (leaf_id, node_mu);
263
266
}
264
267
}
0 commit comments