diff --git a/src/pyhgf/updates/posterior/continuous.py b/src/pyhgf/updates/posterior/continuous.py index 404b03633..a4adf1395 100644 --- a/src/pyhgf/updates/posterior/continuous.py +++ b/src/pyhgf/updates/posterior/continuous.py @@ -348,21 +348,17 @@ def posterior_update_precision_continuous_node( # sum the prediction errors from both value and volatility coupling precision_weigthed_prediction_error = 0.0 - # Value coupling updates - update the precision of a value parent - # --------------------------------------------------------------- - if edges[node_idx].value_children is not None: - for value_child_idx, value_coupling in zip( - edges[node_idx].value_children, # type: ignore - attributes[node_idx]["value_coupling_children"], - ): - precision_weigthed_prediction_error += ( - value_coupling**2 * attributes[value_child_idx]["expected_precision"] - ) - - # cancel the prediction error if the child value was not observed - precision_weigthed_prediction_error *= attributes[value_child_idx][ - "observed" - ] + # Value coupling updates - update the precision of a value parent + # --------------------------------------------------------------- + if edges[node_idx].value_children is not None: + for value_child_idx, value_coupling in zip( + edges[node_idx].value_children, # type: ignore + attributes[node_idx]["value_coupling_children"], + ): + # cancel the prediction error if the child value was not observed + precision_weigthed_prediction_error += ( + value_coupling**2 * attributes[value_child_idx]["expected_precision"] + ) * attributes[value_child_idx]["observed"] # Volatility coupling updates - update the precision of a volatility parent # ------------------------------------------------------------------------- @@ -381,21 +377,17 @@ def posterior_update_precision_continuous_node( "volatility_prediction_error" ] - # sum over all volatility children - precision_weigthed_prediction_error += ( - 0.5 * (volatility_coupling * effective_precision) ** 2 - + (volatility_coupling * effective_precision) ** 2 - * volatility_prediction_error - - 0.5 - * volatility_coupling**2 - * effective_precision - * volatility_prediction_error - ) - - # cancel the prediction error if the child value was not observed - precision_weigthed_prediction_error *= attributes[volatility_child_idx][ - "observed" - ] + # sum over all volatility children + # cancel the prediction error if the child value was not observed + precision_weigthed_prediction_error += ( + 0.5 * (volatility_coupling * effective_precision) ** 2 + + (volatility_coupling * effective_precision) ** 2 + * volatility_prediction_error + - 0.5 + * volatility_coupling**2 + * effective_precision + * volatility_prediction_error + ) * attributes[volatility_child_idx]["observed"] # Compute the new posterior precision # using value prediction errors from both value and volatility coupling