Reject invalid parameter vector during HMC sampling

Hello !

I am trying to use pymc to do Bayesian inference on ODE models. Yet, those models are such that for some values of the parameters vector, the integration will fail (too stiff/requires more precision than the machine’s…). In stan, there exists a reject statement to indicate that the current sampling point is not valid. Is there anything similar in pymc ? Basically my modeling library throws an exception in this case and I would like to simply catch it and deal with it appropriately.


Any chance someone might help me? Let me know if the question isn’t clear.

You can return a logp of -np.inf or np.nan. Both will be treated as a divergence by the sampler.
If you are still working on ode models, you might be interested in sunode:

1 Like