Updating the HGF
In this section we will describe the HGF update process. We update all nodes in an HGF based on an input. This input can either be missing, a single value, a vector of values, or a dictionary of input node names and corresponding values.
The update_hgf!() function call takes an hgf and the input as inputs. All HGF's follow the same update order described in this section. The update process is the following:
We start by updating the predictions from the last timestep of all nodes. First the state nodes, then the input nodes.
We give the first input to the input node. Then in the input node we calculate the value prediction error (prediction from last timestep vs. new input).
(Early update state nodes) We update the input node's value parents posteriors, value prediction error and volatility prediction error
We update the input node's volatility prediction errors
(Late update state nodes) We update the remaining state nodes. We update their posterior, value prediction error and volatility prediciton error.
The update_hgf!() function does not return anything but updates the HGF.
Example of updating the HGF
We deinfe a premade HGF:
using HierarchicalGaussianFiltering
hgf = premade_hgf("help")
hgf = premade_hgf("binary_3level");
update_hgf!(hgf, [1, 0, 1]);
["binary_3level", "categorical_state_transitions", "JGET", "binary_2level", "categorical_3level", "continuous_2level"]
As you can see, the states are updated but only with the last trial saved.
get_states(hgf)
(xvol_prediction_precision = 0.7944207526881872, xbin_posterior_precision = Inf, xbin_prediction_precision = 4.0, xvol_posterior_precision = 0.8901204084183956, xprob_value_prediction_error = 0.44216598162254866, xprob_precision_prediction_error = -0.04887768882605792, xprob_prediction_precision = 0.9811420833457813, xprob_effective_prediction_precision = 0.13234469521244027, xvol_effective_prediction_precision = 0.10751315757409888, xbin_prediction_mean = 0.5, xvol_posterior_mean = -0.003307437930612784, xprob_posterior_precision = 1.1307970779778822, xbin_value_prediction_error = 0.5, xprob_prediction_mean = 0.44216598162254866, xprob_posterior_mean = 0.44216598162254866, u_input_value = 1, xbin_posterior_mean = 1, xvol_precision_prediction_error = missing, xvol_value_prediction_error = -0.003307437930612784, xvol_prediction_mean = -0.003307437930612784)
This page was generated using Literate.jl.