andrey.data.interventions.hard#
- andrey.data.interventions.hard(value=None, *, sd=0.0, probs=None)[source]#
Build a hard intervention: the variable is set from outside, and its parents no longer act.
- Parameters:
value (
float|None) – A continuous variable: its value, or the mean of its values whensdis positive, in the units of the returned data, whatever thescale. A discrete variable: the category every row takes.Nonetakesprobsfor a discrete variable.sd (
float) – A continuous variable: the standard deviation of a Gaussian the values are drawn from, in the units of the returned data.0sets every row tovalue.probs (
Sequence[float] |None) – A discrete variable: the probability of each category, the same for every row.Nonewithvalue=Nonegives every category the same probability.
- Return type:
- Raises:
ValueError – If
valueorsdis not finite,sdis negative,probsis given withvalueorsd, orprobshas a negative entry or does not sum to 1.
Examples
>>> from andrey.data.interventions import hard >>> hard(2.0, sd=0.2) HardIntervention(value=2.0, sd=0.2, probs=None)