TuringLang / AdvancedMH.jl

Robust implementation for random-walk Metropolis-Hastings algorithms
https://turinglang.org/AdvancedMH.jl/
MIT License
91 stars 17 forks source link

Tracking acceptances #40

Open cpfiffer opened 3 years ago

cpfiffer commented 3 years ago

We are not currently tracking acceptances, which is a statistic that could be useful for manual tuning. We need to change the Transition struct to track accept/reject.

In addition to this, the AdpativeProposal code in from #39 has some legacy stuff that mutates the sampler in place, as opposed to tracking the total number of draws. A fix for this would allow the AdaptiveProposal code to track the total number of draws within each Transition, so any mutation can be removed from the system.

Check out this discussion for more context.

sellingsrud commented 2 years ago

What's the status on this?

cpfiffer commented 2 years ago

No change, happy to accept PRs!

sellingsrud commented 2 years ago

Gotcha, I'll see if I manage to put in some effort.

This is in principle pretty simple right? (And simpler than implementing an adaptive scheme which tunes it for you).

Is it enough to change the Transition struct to keep a number of draws and number of accepted, and include the correct arithmetic in the AbstractMCMC.step function so that the new Transition created has updated acceptance rate?

My concern doing this myself is that it requires efficiency, which is not my strong suit in Julia.

For example, does it slow down a lot if I change from returning transition_prev if not accepted to making a new Transition object and returning that?

ParadaCarleton commented 1 year ago

Gotcha, I'll see if I manage to put in some effort.

This is in principle pretty simple right? (And simpler than implementing an adaptive scheme which tunes it for you).

Is it enough to change the Transition struct to keep a number of draws and number of accepted, and include the correct arithmetic in the AbstractMCMC.step function so that the new Transition created has updated acceptance rate?

My concern doing this myself is that it requires efficiency, which is not my strong suit in Julia.

For example, does it slow down a lot if I change from returning transition_prev if not accepted to making a new Transition object and returning that?

Hi, thanks for offering to help! I don't think this would make a lot of difference to efficiency, and you shouldn't worry too much about precisely optimizing the code here. Feel free to make a PR!