I was looking at the base_hmc.hpp implementation, because I’ve been trying to implement it in R, and I found something peculiar.

Say we have an old tree with weight w_{\mathrm{old}}, and we just built a new tree with weight w_{\mathrm{new}}. As I understand, the rule is that if w_{\mathrm{new}} > w_{\mathrm{old}} then we sample from the new tree.

This is what is checked at line 136 of the linked file: `log_sum_weight_subtree`

is the log of w_{\mathrm{new}}, and `log_sum_weight`

is the log of w_{\mathrm{old}}. Once this if-else statement finishes executing, then `log_sum_weight`

is updated to be the log of the sum of both weights.

Now, I noticed that this contrasts with the analogous multinomial sampling that occurs in the `build_tree(.)`

function at line 278. Here, `log_sum_weight_right`

indeed represents the log of w_{\mathrm{new}}, but it is being compared to `log_sum_weight_subtree`

which at this point in the code is set to \log(w_{\mathrm{new}} + w_{\mathrm{old}}). Should it not instead be compared to `log_sum_weight_left`

which represents the log of w_{\mathrm{old}}?

I’m probably missing something, but I just can’t figure out what. Can anyone chime in?