HMC with Bernoulli variable? #550
Replies: 1 comment
-
You unfortunately can't run HMC on discrete variables! And yes, it makes sense to instead write a MCMC algorithm which applies HMC to some variables and regular MH (or another MCMC kernel) to the discrete variables. We don't have a HMC tutorial right now I believe -- partly because the HMC implementation in Gen.jl is far from optimized -- but as a starting point, you can try modifying the inference algorithm over the Bayesian linear regression with outliers model in this tutorial: https://www.gen.dev/tutorials/iterative-inference/tutorial#mcmc-2 In part 5 of that tutorial, there is a compound MCMC kernel called For your example model (which we call an "undisciplined generative function" in the Gen docs), the support of |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to run HMC on a fairly complicated generative model for the sake of efficiency. Importance resampling/MH work but they don't do particularly well on reconstructing the prior distribution (i.e. inferring the right parameters for the forward simulation). Here's a minimal example of the core issue. I have a generative function that flips a coin and determine the support for another variable
a
.In terms of inference, I want to infer the value for flip based on the observation for
a
.I run into an error if I try to do a single step of HMC for both
flip
anda
I understand that the Bernoulli variable doesn't have a gradient but I'm wondering if there's a workaround. Does it make sense to do
mh
forflip
andhmc
for the rest? Also, is there a tutorial for HMC on Gen.dev?Beta Was this translation helpful? Give feedback.
All reactions