API reference

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 when sd is positive, in the units of the returned data, whatever the scale. A discrete variable: the category every row takes. None takes probs for 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. 0 sets every row to value.

  • probs (Sequence[float] | None) – A discrete variable: the probability of each category, the same for every row. None with value=None gives every category the same probability.

Return type:

HardIntervention

Raises:

ValueError – If value or sd is not finite, sd is negative, probs is given with value or sd, or probs has 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)