For Hamiltonian Monte Carlo, what should be done when one of the steps in the leapfrog path yields no solution? When estimating a very complex (potentially discontinuous) model with Hamiltonian Monte Carlo, what should be done when one of the steps in the leapfrog path yields no solution? The issue is that evaluating the gradient at these points is nonsensical. Are there known work-arounds for this problem?
One thought I had would be throwing the entire draw away, but it seems like this might be needlessly inefficient. (A slight step in the ball around a particular point could yield a solution.)
Any help or references would be much appreciated!
 A: For the most basic version of HMC, the procedure is: 


*

*using the leapfrog integrator, generate a trajectory $L$ steps long, which approximates Hamiltonian dynamics 

*propose a move to the $L^{\text{th}}$ point on that trajectory

*accept or reject this proposed move using a Metropolis-Hastings correction.


In the situation you describe, step 1 fails - or equally, step 2 fails, as there is no $L^{\text{th}}$ point. The `correct' thing to do would thus be to throw away the entire draw. 
For more advanced variants of HMC (e.g. the No U-Turn Sampler), the procedure is closer to


*

*using the leapfrog integrator, generate a trajectory of some length, which approximates Hamiltonian dynamics, and eventually terminates

*compute a weight $w_i$ for each point $(x_i, p_i)$ on the trajectory

*move to the point $(x_i, p_i)$ with probability proportional to $w_i$
In this case, you would be alright - you would essentially throw away the `failed' part of the trajectory (assuming it's entered a part of the space with $0$ probability), and select your new point from among the successful steps.
If your procedure fails because you can't compute a gradient, even though you are still in a region of positive probability, then HMC is perhaps not an appropriate tool. Without consistent access to gradient information in the support of your target distribution, it is not clear that using HMC makes sense.
