Open furibec opened 1 month ago
These are the step sizes (epsilon) results for NUTS and HMC. They both use the same Dual Averaging algorithm to adapt the epsilon. Note, however, that in HMC after warm-up, the step sizes keep changing. This is because we have to do a jittering of the epsilons in order to avoid pathological behavior
and this is the result for the main statistics estimated by NUTS and HMC. For HMC we fixed the trajectory length to 150 (as per Neal's example), this is the main contribution of NUTS, which adapts this parameter using the no-U-turn BuildTree
(other than that, NUTS is plain HMC). Here we are sampling a 100-dimensional Gaussian with zero mean and diagonal covariance. The samples are both estimating very well the reference mean and standard deviations.
Explanation: Left plot - closer to zero is better. Right plot - closer to the (0,0)-(1,1) line is better. We can even compare with RWM and see that it is not able to estimate this problem as good as HMC/NUTS
I believe the samplers are working as expected and they are also in CUQIpy format. Nevertheless, some test are failing due to the changes I did in NUTS. I hope someone can take it from here @jakobsj
Thank you very much @furibec for adding your HMC sampler, the fixes as well as a demo validating the implementation, that is most helpful! I cannot promise when we'll be able to look at this but I hope it will be soon.
_hmc.py
contained the NUTS implementation, so I renamed it to_nuts.py
neg_Hamiltonian
function and added some explanation, improved epsilon adaptation functions, and a few changes in theBuildTree
while I was checking everything looks correct.