Introduce sampling dependency for auxiliary nodes in SearchForExplanation
#578
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Search cases where antecedent and witness candidates overlap occur fairly naturally when we suspect a node to be a cause and we also want to allow it to be a witness when testing other nodes as antecedents (same run forward, different samples). Ideally, we should be able to do this in a single search.
Currently, however, witness and antecedent auxiliary nodes are sampled independently. This, among other things, means that if an antecedent candidate is not preempted (i.e. we intend to execute an antecedent intervention) the witness auxiliary node can still be one (stochastically), effectively preempting this antecedent intervention.
This is not the intended behavior. We know that if a node is considered as an antecedent, it should not be at the same time treated as a potential witness, and so the intended behavior should be that witness sampling is reserved for samples in which the antecedent intervention is not performed, effectively setting witness preemption
case
to 0 if the antecedent preemption case is0
. Not doing so not only leads to inefficient sampling, but also might skew the probability estimates if they involve conditioning on the antecedent intervention being performed but the user forgets to condition at the same time on that node not being a witness.This PR allows for improved behavior by pulling case sampling outside of the handlers and passing the sampled and dependency-corrected cases forward to the handlers.
The API is backward compatible - if
num_samples
andsampling_dimension
are not passed, we default to the old behavior, which is sufficient for the more limited search cases that we have been using so far.