pub struct CausalExprArena { /* private fields */ }Expand description
Arena for causal expressions with interned variable sets.
Implementations§
Source§impl CausalExprArena
impl CausalExprArena
Sourcepub fn compile(&self, root: ExprId) -> Result<CompiledEvaluator, EvalError>
pub fn compile(&self, root: ExprId) -> Result<CompiledEvaluator, EvalError>
Compile root into a topological evaluation plan.
Continuous ExprNode::IntegralOut compiles successfully; evaluation uses
DistributionProvider::quadrature or discrete DistributionProvider::support.
Source§impl CausalExprArena
impl CausalExprArena
Sourcepub fn intern_var_set(
&mut self,
vars: impl IntoIterator<Item = VariableId>,
) -> VarSetId
pub fn intern_var_set( &mut self, vars: impl IntoIterator<Item = VariableId>, ) -> VarSetId
Intern a sorted variable set (sorts and dedups input).
Sourcepub fn intern_intervention_assignments(
&mut self,
assignments: impl IntoIterator<Item = InterventionAssignment>,
) -> InterventionSetId
pub fn intern_intervention_assignments( &mut self, assignments: impl IntoIterator<Item = InterventionAssignment>, ) -> InterventionSetId
Intern a hard-intervention assignment set (sorted by variable id).
Sourcepub fn intern_intervention_set(
&mut self,
vars: impl IntoIterator<Item = VariableId>,
) -> InterventionSetId
pub fn intern_intervention_set( &mut self, vars: impl IntoIterator<Item = VariableId>, ) -> InterventionSetId
Intern an intervention over variables only (value unspecified / placeholder).
Sourcepub fn empty_var_set(&mut self) -> VarSetId
pub fn empty_var_set(&mut self) -> VarSetId
Empty var set.
Sourcepub fn empty_intervention_set(&mut self) -> InterventionSetId
pub fn empty_intervention_set(&mut self) -> InterventionSetId
Empty intervention set.
Sourcepub fn var_set(&self, id: VarSetId) -> &[VariableId]
pub fn var_set(&self, id: VarSetId) -> &[VariableId]
Look up a var set.
Sourcepub fn intervention_assignments(
&self,
id: InterventionSetId,
) -> &[InterventionAssignment]
pub fn intervention_assignments( &self, id: InterventionSetId, ) -> &[InterventionAssignment]
Look up intervention assignments.
Sourcepub fn intervention_set(&self, id: InterventionSetId) -> Vec<VariableId>
pub fn intervention_set(&self, id: InterventionSetId) -> Vec<VariableId>
Variables appearing in an intervention set (legacy helper).
Sourcepub fn intern_list(
&mut self,
exprs: impl IntoIterator<Item = ExprId>,
) -> ExprListId
pub fn intern_list( &mut self, exprs: impl IntoIterator<Item = ExprId>, ) -> ExprListId
Intern an expression list.
Sourcepub fn list(&self, id: ExprListId) -> &[ExprId]
pub fn list(&self, id: ExprListId) -> &[ExprId]
Borrow an interned expression list.
Sourcepub fn set_derivation(&mut self, id: ExprId, meta: DerivationMeta)
pub fn set_derivation(&mut self, id: ExprId, meta: DerivationMeta)
Attach derivation metadata (does not affect semantic equality).
Sourcepub fn set_derivation_if_absent(&mut self, id: ExprId, meta: DerivationMeta)
pub fn set_derivation_if_absent(&mut self, id: ExprId, meta: DerivationMeta)
Attach derivation metadata only when absent (never overwrites ID rules).
Sourcepub fn simplify(&mut self, root: ExprId) -> Result<ExprId, SimplifyError>
pub fn simplify(&mut self, root: ExprId) -> Result<ExprId, SimplifyError>
Simplify root with worklist-style bottom-up rewrite + memoization.
§Errors
SimplifyError if a SumOut/IntegralOut binds a variable absent from its
body’s free variables — an ill-formed estimand. See SimplifyError docs.
Sourcepub fn derivation(&self, id: ExprId) -> Option<&DerivationMeta>
pub fn derivation(&self, id: ExprId) -> Option<&DerivationMeta>
Borrow derivation metadata.
Sourcepub fn var_set_count(&self) -> usize
pub fn var_set_count(&self) -> usize
Number of interned variable sets (for serialization).
Sourcepub fn intervention_set_count(&self) -> usize
pub fn intervention_set_count(&self) -> usize
Number of interned intervention sets (for serialization).
Sourcepub fn list_count(&self) -> usize
pub fn list_count(&self) -> usize
Number of interned expression lists (for serialization).
Sourcepub fn backdoor_ate(
&mut self,
treatment: VariableId,
outcome: VariableId,
adjustment: &[VariableId],
active: Value,
control: Value,
) -> ExprId
pub fn backdoor_ate( &mut self, treatment: VariableId, outcome: VariableId, adjustment: &[VariableId], active: Value, control: Value, ) -> ExprId
Build the backdoor adjustment functional for ATE:
E[Y | do(T=active)] − E[Y | do(T=control)] under adjustment by Z.
Sourcepub fn frontdoor_ate(
&mut self,
treatment: VariableId,
outcome: VariableId,
mediators: &[VariableId],
active: Value,
control: Value,
) -> ExprId
pub fn frontdoor_ate( &mut self, treatment: VariableId, outcome: VariableId, mediators: &[VariableId], active: Value, control: Value, ) -> ExprId
Build the front-door functional for ATE:
E[Y | do(T=active)] − E[Y | do(T=control)], mediated through M via
sum_m P(m | t) * sum_t' P(y | m, t') P(t') (FD condition 2 reduces
P(m | do(t)) to the observational P(m | t)).
Sourcepub fn temporal_mediation_ate(
&mut self,
treatment: VariableId,
outcome: VariableId,
mediators: &[VariableId],
active: Value,
control: Value,
) -> ExprId
pub fn temporal_mediation_ate( &mut self, treatment: VariableId, outcome: VariableId, mediators: &[VariableId], active: Value, control: Value, ) -> ExprId
Linear temporal-mediation path-product ATE contrast (same product-of-coefficients
geometry as front-door under a linear SEM, tagged temporal_mediation — not front-door).
Sourcepub fn iv_wald(
&mut self,
treatment: VariableId,
outcome: VariableId,
instruments: &[VariableId],
active: &Value,
control: &Value,
) -> ExprId
pub fn iv_wald( &mut self, treatment: VariableId, outcome: VariableId, instruments: &[VariableId], active: &Value, control: &Value, ) -> ExprId
Build the Wald IV functional for binary instrument Z:
(E[Y|Z=1] − E[Y|Z=0]) / (E[T|Z=1] − E[T|Z=0]).
active / control are recorded in derivation metadata (treatment contrast
scaling); the ratio itself conditions on instrument levels 1 and 0.
Trait Implementations§
Source§impl Clone for CausalExprArena
impl Clone for CausalExprArena
Source§fn clone(&self) -> CausalExprArena
fn clone(&self) -> CausalExprArena
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more