When a decision changes the data-generating process, prediction from the original environment no longer answers the causal question. An intervention distribution describes the outcomes produced after externally setting one or more variables. For an ideal intervention, the target is fixed to a value and disconnected from its causal parents; stochastic interventions choose the value through a random process. Causal effects compare such distributions, as in ATE = E(Y|do(X=1)) − E(Y|do(X=0)). section 7.7
Operationalize an intervention distribution by:
- Specify the target variable and intervention value, distinguishing external setting from merely conditioning on an observed value. section 7.7 section 13.3.3
- Alter the causal model with an intervention operator: replace a structural assignment, perform graph surgery, or replace the target kernel with a point mass. section 7.7
- Sample from the altered model to simulate experiments, estimate outcomes, or compare intervention distributions with observational and counterfactual distributions. section 7.7 section 9.3.4
Setting femur length in a Pyro model
Applying pyro.do(model, data={"femur": tensor(46.0)}) creates a hypothetical model in which femur length is fixed at 46 cm. Repeatedly calling that model generates samples from the corresponding intervention distribution. Supplying an inferred exogenous-variable distribution instead produces a counterfactual distribution conditioned on the actual world; comparing histograms makes the difference visible. section 9.3.4
int_model = pyro.do(model, data={"femur": tensor(46.0)})
Inspect the compact Pyro operation that fixes a causal variable before sampling from the altered model. section 9.3.4

