ni-phy / year4-project

0 stars 0 forks source link

Acceptance rate #6

Closed ni-phy closed 3 years ago

ni-phy commented 3 years ago

Hey @grd349

In the tfp_hmc file, I implemented the HMC on the GP but I get an acceptance rate 0.0, from what I understand this is a problem. I tried changing the initial parameters and kernel. I checked and the run_mcmc function is called. Not quite sure what is causing the problem. There's no error or warning when running the code. I've added the residual and z-statistic plots. Any ideas? image image

grd349 commented 3 years ago

I implemented the HMC on the GP but I get an acceptance rate 0.0,

Did you specify step sizes in the HMC implementation? If yes, reduce them by a factor of 100 and see if things improve. If the acceptance rate is still zero then reduce the step sizes by another factor 100.

Once the step sizes give acceptance rates that are not zero, it's a case of adjusting the step sizes until you get good mixing. Does TFP have a method that estimates the auto-correlation of chains?

ni-phy commented 3 years ago

Reducing the step sized worked. Thanks! I couldn't find anything about estimating auto-correlation. In the documentation, they recommend introducing extra steps between the steps that make it into the results to reduce the correlation between steps, which I set to 3. These are the results I get using that. image image

grd349 commented 3 years ago

So the ACF is not essential but we do need to check that the HMC sampler is really drawing samples from the target distribution and that these samples are well mixed. Do you know anything about Gelman-Rubin statistics or number of effective samples? I can send you a link ....

ni-phy commented 3 years ago

I don't know about either, a link would be perfect. Thanks!

grd349 commented 3 years ago

Here is a link to the Stan user guide

https://mc-stan.org/users/documentation/

It is excellent documentation! You can find the discussion of the effective sample size here

https://mc-stan.org/docs/2_18/reference-manual/effective-sample-size-section.html

It also includes a discussion of thinning.

It's a little hard to follow IMHO but a necessary step. Henry is lucky that PyMC3 does this all for him. For your work you could see if you can use https://arviz-devs.github.io/arviz/ for some of the things you might want to calculate.

Hope this helps rather than hinders,

G

Dr Guy R. Davies PI - ERC CartographY Project Senior Lecturer in Astrophysics School of Physics and Astronomy The University of Birmingham Edgbaston Birmingham B15 2TT

Tel +44 (0) 121 414 4597 G.R.Davies@bham.ac.uk grd349@gmail.com davies@bison.ph.bham.ac.u davies@bison.ph.bham.ac.ukk davies@bison.ph.bham.ac.uk

The contents of this e-mail may be privileged and are confidential. It may not be disclosed, used, or copied in any way by anyone other than the addressee. If received in error please notify the sender then delete it from your system. Should you communicate with the sender by e-mail, you consent to The University of Birmingham monitoring and reading any such correspondence.

On Fri, 11 Dec 2020 at 16:48, ni-phy notifications@github.com wrote:

I don't know about either, a link would be perfect. Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ni-phy/year4-project/issues/6#issuecomment-743303857, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADQZOCIIS6PKZSTWLME5IBTSUJEO3ANCNFSM4UU5LC4A .