pyhgf.updates.vectorized.binary.vectorized_binary_prediction#

pyhgf.updates.vectorized.binary.vectorized_binary_prediction(child_state, parent_state, weights, coupling_fn=<PjitFunction of <function tanh>>, parent_has_constant=False)[source]#

Predict expected mean and precision for a binary state node layer.

The expected mean is the sigmoid of the weighted parent predictions:

\[\begin{split}\\hat{\\mu}_b = \\sigma(W \\cdot g(\\hat{\\mu}_a))\end{split}\]

The expected precision is the Bernoulli variance:

\[\begin{split}\\hat{\\pi}_b = \\hat{\\mu}_b (1 - \\hat{\\mu}_b)\end{split}\]

Note

The expected_precision field actually stores the variance (i.e. uncertainty) of the Bernoulli distribution. Using this name avoids the need for a separate posterior update step for binary nodes: the continuous parent’s posterior update can consume the binary prediction error directly.

Parameters:
  • child_state (LayerState) – Current state of the binary child layer (being predicted).

  • parent_state (LayerState) – Current state of the parent layer (predictor).

  • weights (Array) – Weight matrix connecting child to parent, shape (n_children, n_parents) or (n_children, n_parents + 1) when the parent layer includes a constant input node.

  • coupling_fn (Callable) – Coupling function applied to parent means (default: tanh).

  • parent_has_constant (bool) – If True, the parent layer has a constant input node (mean = 1.0) appended to its activations.

Returns:

Updated child layer state with binary expected values.

Return type:

LayerState