CUQI-DTU / CUQIpy

https://cuqi-dtu.github.io/CUQIpy/
Apache License 2.0
41 stars 7 forks source link

HMC sampler #449

Open furibec opened 1 month ago

furibec commented 1 month ago
furibec commented 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 image

furibec commented 1 month ago

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 image

furibec commented 1 month ago

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

jakobsj commented 1 month ago

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.