In the file `base_nuts.hpp`

I see a lot of occurrences of the expression

log_sum_weight = math::log_sum_exp(log_sum_weight, H0 - h);

It is used in the recursive construction of binary trees and is initiated to have a value of 0.

double log_sum_weight = 0; // log(exp(H0 - H0))

I think this has to do with Neal’s window method and we are trying to calculate the probability of acceptance of the subtree taken as a “window”.

However, since exp(H0- h) = pi(h)/pi(H_0) and adding this term along the trajectory gives log( exp(h_0-h_1) + exp(h_1-h_2) + … + exp(h_{k-1}-h_{k}))

where h_0,…,h_k are the states in the trajectory aka the leaves of the subtree

I don’t see how it gives log( exp(-h_0) + … + exp(-h_k)) which is what we need to calculate the probability of acceptance of the subtree. What was I missing?