Conditional deterministic variable

In my PyMC model there exists a conditional statement within the model. I wish to have the sampler consider the value of a deterministic variable to be valid only when this condition is true.

I believe it used to possible to return i.e. -np.inf for a draw to be rejected, but this seems to cause some issues with the current version of PyMC. This seems sort of like an anti-pattern anyway.

Any alternatives here?

This may be helpful: pymc.model.core.Potential — PyMC dev documentation

However it’s better to avoid hard constraints when sampling with NUTS, since it requires some degree of continuity. It’s usually possible to write constrains in a more soft continuous way or by being clever about variable priors.

This works. Thanks a lot!