Overview of all functions in the Hierarchical Gaussian Filtering package
HierarchicalGaussianFiltering.BinaryInputNodeHistory — Type
Configuration of history of binary input node
HierarchicalGaussianFiltering.BinaryInputNodeParameters — Type
Configuration of parameters in binary input node. Default category mean set to [0,1]
HierarchicalGaussianFiltering.BinaryInputNodeState — Type
Configuration of states of binary input node
HierarchicalGaussianFiltering.BinaryStateNode — Type
Overview of edge posibilities
HierarchicalGaussianFiltering.BinaryStateNodeHistory — Type
Overview of the history of the binary state node
HierarchicalGaussianFiltering.BinaryStateNodeParameters — Type
Configure parameters of binary state node
HierarchicalGaussianFiltering.BinaryStateNodeState — Type
Overview of the states of the binary state node
HierarchicalGaussianFiltering.CategoricalInputNodeHistory — Type
History of categorical input node
HierarchicalGaussianFiltering.CategoricalInputNodeState — Type
Configuration of states of categorical input node
HierarchicalGaussianFiltering.CategoricalStateNode — Type
Configuration of edges in categorical state node
HierarchicalGaussianFiltering.CategoricalStateNodeHistory — Type
Configuration of history in categorical state node
HierarchicalGaussianFiltering.CategoricalStateNodeState — Type
Configuration of states in categorical state node
HierarchicalGaussianFiltering.ContinuousInputNodeHistory — Type
Configuration of continuous input node history
HierarchicalGaussianFiltering.ContinuousInputNodeParameters — Type
Configuration of continuous input node parameters
HierarchicalGaussianFiltering.ContinuousInputNodeState — Type
Configuration of continuous input node states
HierarchicalGaussianFiltering.ContinuousStateNodeHistory — Type
Configuration of continuous state node history
HierarchicalGaussianFiltering.ContinuousStateNodeParameters — Type
Configuration of continuous state nodes' parameters
HierarchicalGaussianFiltering.ContinuousStateNodeState — Type
Configurations of the continuous state node states
ActionModels.reset! — Method
reset!(hgf::HGF)Reset an HGF to its initial state.
HierarchicalGaussianFiltering.calculate_log_predicted_volatility — Method
calculate_log_predicted_volatility(node::ContinuousStateNode, child::ContinuousStateNode, node_value::Real)Calculates the log of a volatility child's predicted volatility (including the stepsize) as a function of the node's value. The part which does not depend on the node is recovered from the child's prediction, which was made with the node's previous posterior mean. This function is only used in the unbounded HGF update.
HierarchicalGaussianFiltering.calculate_posterior — Method
calculate_posterior(node::CategoricalStateNode)Calculate the posterior for a categorical state node.
HierarchicalGaussianFiltering.calculate_posterior_mean — Method
calculate_posterior_mean(node::BinaryStateNode)Calculates a node's posterior mean.
HierarchicalGaussianFiltering.calculate_posterior_mean — Method
calculate_posterior_mean(node::AbstractNode)Calculates a node's posterior mean.
HierarchicalGaussianFiltering.calculate_posterior_precision — Method
calculate_posterior_precision(node::BinaryStateNode)Calculates a binary node's posterior precision.
HierarchicalGaussianFiltering.calculate_posterior_precision — Method
calculate_posterior_precision(node::AbstractNode)Calculates a node's posterior precision.
HierarchicalGaussianFiltering.calculate_posterior_precision_increment — Method
calculate_posterior_precision_vope(node::AbstractNode, child::AbstractNode)Calculates the posterior precision update term for a single continuous volatility child to a state node.
HierarchicalGaussianFiltering.calculate_precision_prediction_error — Method
calculate_precision_prediction_error(node::ContinuousInputNode)Calculates an input node's volatility prediction error.
HierarchicalGaussianFiltering.calculate_precision_prediction_error — Method
calculate_precision_prediction_error(node::AbstractNode)Calculates a state node's volatility prediction error.
HierarchicalGaussianFiltering.calculate_prediction — Method
function calculate_prediction(node::CategoricalStateNode)Calculate the prediction for a categorical state node.
HierarchicalGaussianFiltering.calculate_prediction_mean — Method
calculate_prediction_mean(node::BinaryStateNode)Calculates a binary state node's prediction mean.
HierarchicalGaussianFiltering.calculate_prediction_mean — Method
calculate_prediction_mean(node::AbstractNode)Calculates a node's prediction mean.
HierarchicalGaussianFiltering.calculate_prediction_precision — Method
calculate_prediction_precision(node::BinaryStateNode)Calculates a binary state node's prediction precision.
HierarchicalGaussianFiltering.calculate_prediction_precision — Method
calculate_prediction_precision(node::AbstractInputNode)Calculates an input node's prediction precision.
HierarchicalGaussianFiltering.calculate_prediction_precision — Method
calculate_prediction_precision(node::AbstractNode)Calculates a node's prediction precision.
HierarchicalGaussianFiltering.calculate_unbounded_expansion_point — Method
calculate_unbounded_expansion_point(node::ContinuousStateNode, child::ContinuousStateNode, prior_precision::Real, prior_mean::Real)Finds the expansion point for the second expansion of the unbounded HGF update: the approximate secondary mode of the variational energy created by a volatility child, in the limit where the variance carried over from the child's previous posterior goes to zero. The mode is found in closed form with the Lambert W function, in the canonical variable y = log(t) + κx + ω, which is the log of the child's predicted volatility. This function is only used in the unbounded HGF update.
HierarchicalGaussianFiltering.calculate_unbounded_first_expansion — Method
calculate_unbounded_first_expansion(node::ContinuousStateNode, prior_precision::Real, prior_mean::Real)Makes the first quadratic expansion of the unbounded HGF update, at the prior mean. The precision uses only the concave part of the variational energy, so it is always positive. Returns the precision and mean of the expansion. This function is only used in the unbounded HGF update.
HierarchicalGaussianFiltering.calculate_unbounded_posterior — Method
calculate_unbounded_posterior(node::ContinuousStateNode, prior_mean::Real)Calculates the posterior precision and mean of a continuous state node with volatility children, using the unbounded HGF update (Mathys et al., 2026). The node's variational energy is approximated with quadratic expansions: a first expansion at the prior mean, which uses only the concave part of the variational energy and therefore always has a positive precision, and a second expansion for each volatility child, at the approximate secondary mode of the variational energy which that child can create, found with the Lambert W function. The expansions are weighted with a softmax over the variational energy at their means, and the posterior is the moment-matched Gaussian of the resulting mixture, so that the posterior precision is positive by construction. The effective prior, which includes the update terms from all children that are not volatility children, is given by the node's stored posterior precision and the passed prior mean.
HierarchicalGaussianFiltering.calculate_unbounded_second_expansion — Method
calculate_unbounded_second_expansion(node::ContinuousStateNode, child::ContinuousStateNode, prior_precision::Real, prior_mean::Real)Makes the second quadratic expansion of the unbounded HGF update for a single volatility child, at the approximate secondary mode of the variational energy which that child can create. The full variational energy, with the contributions from all volatility children, is expanded at this point. Returns the precision and mean of the expansion, or nothing if the expansion is not finite. This function is only used in the unbounded HGF update.
HierarchicalGaussianFiltering.calculate_value_prediction_error — Method
calculate_value_prediction_error(node::AbstractNode)Calculate's a state node's value prediction error.
HierarchicalGaussianFiltering.calculate_value_prediction_error — Method
calculate_value_prediction_error(node::CategoricalStateNode)Calculate the value prediction error for a categorical state node.
HierarchicalGaussianFiltering.calculate_value_prediction_error — Method
calculate_value_prediction_error(node::ContinuousInputNode)Calculate's an input node's value prediction error.
HierarchicalGaussianFiltering.calculate_value_prediction_error — Method
calculate_value_prediction_error(node::AbstractNode)Calculate's a state node's value prediction error.
HierarchicalGaussianFiltering.calculate_variational_energy — Method
calculate_variational_energy(node::ContinuousStateNode, node_value::Real, prior_precision::Real, prior_mean::Real)Calculates the variational energy of a continuous state node with volatility children, at a given value of the node (up to a constant). This is the quadratic prior term plus the contributions from each volatility child. This function is only used in the unbounded HGF update.
HierarchicalGaussianFiltering.calculate_volatility_coupling_terms — Method
calculate_volatility_coupling_terms(node::ContinuousStateNode, child::ContinuousStateNode, node_value::Real)For a volatility child, calculates the terms of the unbounded HGF update which depend on the node's value: the child's effective prediction precision (the proportion of its predicted variance that comes from the predicted volatility), its precision prediction error, and its contribution to the node's variational energy. These are calculated in log-space, so that they stay finite when the predicted volatility under- or overflows. This function is only used in the unbounded HGF update.
HierarchicalGaussianFiltering.check_hgf — Method
check_hgf(hgf::HGF)Check whether an HGF has specified correctly. A single node can also be passed.
HierarchicalGaussianFiltering.enter_node_inputs! — Method
enter_node_inputs!(hgf::HGF, input)Set input values in input nodes. Can either take a single value, a vector of values, or a dictionary of input node names and corresponding values.
HierarchicalGaussianFiltering.get_prediction — Function
get_prediction(hgf::HGF, node_name::String)Get the prediction for the next timestep for a specified node in an HGF. If an agent is passed instead of an HGF, the HGF is extracted from the substruct in the agent. A single node can also be passed.
HierarchicalGaussianFiltering.get_surprise — Function
getsurprise(hgf::HGF, nodename::String = "u")
Calculates the surprisal at the last input of a specified input node in an HGF. If an agent is passed instead of an HGF, the HGF is extracted from the substruct in the agent. If no node is specified, the surprisal of all input nodes is summed.
HierarchicalGaussianFiltering.get_surprise — Method
get_surprise(node::CategoricalInputNode)Calculate the surprise of a categorical input node on seeing the last input.
HierarchicalGaussianFiltering.get_surprise — Method
get_surprise(node::ContinuousInputNode)Calculate the surprise of an input node on seeing the last input.
HierarchicalGaussianFiltering.lambert_w0_from_log — Method
lambert_w0_from_log(log_argument::Real)The principal branch W₀ of the Lambert W function, which solves w * exp(w) = z for z ≥ 0, given the log of its argument z. Taking the log of the argument means that z itself never has to be represented, so it can be far above the largest representable number. Uses Halley's method, which converges to machine precision in a few iterations. The iteration is written in terms of the residual w - exp(log(z) - w), so that no intermediate value can overflow. This function is only used in the unbounded HGF update.
HierarchicalGaussianFiltering.premade_JGET — Method
premade_JGET(config::Dict; verbose::Bool = true)
The HGF used in the JGET model. It has a single continuous input node u, with a value parent x, and a volatility parent xnoise. x has volatility parent xvol, and xnoise has a volatility parent xnoise_vol.
Config defaults:
- ("u", "input_noise"): -2
- ("x", "volatility"): -2
- ("xvol", "volatility"): -2
- ("xnoise", "volatility"): -2
- ("xnoise_vol", "volatility"): -2
- ("u", "x", "coupling_strength"): 1
- ("u", "xnoise", "coupling_strength"): 1
- ("x", "xvol", "coupling_strength"): 1
- ("xnoise", "xnoisevol", "couplingstrength"): 1
- ("x", "initial_mean"): 0
- ("x", "initial_precision"): 1
- ("xvol", "initial_mean"): 0
- ("xvol", "initial_precision"): 1
- ("xnoise", "initial_mean"): 0
- ("xnoise", "initial_precision"): 1
- ("xnoisevol", "initialmean"): 0
- ("xnoisevol", "initialprecision"): 1
HierarchicalGaussianFiltering.premade_binary_2level — Method
premade_binary_2level(config::Dict; verbose::Bool = true)The standard binary 2 level HGF model, which takes a binary input, and learns the probability of either outcome. It has one binary input node u, with a binary value parent xbin, which in turn has a continuous value parent xprob.
Config defaults:
HierarchicalGaussianFiltering.premade_binary_3level — Method
premade_binary_3level(config::Dict; verbose::Bool = true)The standard binary 3 level HGF model, which takes a binary input, and learns the probability of either outcome. It has one binary input node u, with a binary value parent xbin, which in turn has a continuous value parent xprob. This then has a continunous volatility parent xvol.
This HGF has five shared parameters: "xprobvolatility" "xprobinitialprecisions" "xprobinitialmeans" "couplingstrengthsxbinxprob" "couplingstrengthsxprob_xvol"
Config defaults:
- ("xprob", "volatility"): -2
- ("xvol", "volatility"): -2
- ("xbin", "xprob", "coupling_strength"): 1
- ("xprob", "xvol", "coupling_strength"): 1
- ("xprob", "initial_mean"): 0
- ("xprob", "initial_precision"): 1
- ("xvol", "initial_mean"): 0
- ("xvol", "initial_precision"): 1
HierarchicalGaussianFiltering.premade_categorical_3level — Method
premade_categorical_3level(config::Dict; verbose::Bool = true)The categorical 3 level HGF model, which takes an input from one of n categories and learns the probability of a category appearing. It has one categorical input node u, with a categorical value parent xcat. The categorical node has a binary value parent xbinn for each category n, each of which has a continuous value parent xprobn. Finally, all of these continuous nodes share a continuous volatility parent xvol. Setting parameter values for xbin and xprob sets that parameter value for each of the xbinn and xprobn nodes.
Config defaults:
- "n_categories": 4
- ("xprob", "volatility"): -2
- ("xvol", "volatility"): -2
- ("xbin", "xprob", "coupling_strength"): 1
- ("xprob", "xvol", "coupling_strength"): 1
- ("xprob", "initial_mean"): 0
- ("xprob", "initial_precision"): 1
- ("xvol", "initial_mean"): 0
- ("xvol", "initial_precision"): 1
HierarchicalGaussianFiltering.premade_categorical_state_transitions — Method
premade_categorical_state_transitions(config::Dict; verbose::Bool = true)The categorical state transition 3 level HGF model, learns state transition probabilities between a set of n categorical states. It has one categorical input node u, with a categorical value parent xcatn for each of the n categories, representing which category was transitioned from. Each categorical node then has a binary parent xbinnm, representing the category m which the transition was towards. Each binary node xbinnm has a continuous parent xprobnm. Finally, all of these continuous nodes share a continuous volatility parent xvol. Setting parameter values for xbin and xprob sets that parameter value for each of the xbinnm and xprobn_m nodes.
This HGF has five shared parameters: "xprobvolatility" "xprobinitialprecisions" "xprobinitialmeans" "couplingstrengthsxbinxprob" "couplingstrengthsxprob_xvol"
Config defaults:
- "n_categories": 4
- ("xprob", "volatility"): -2
- ("xvol", "volatility"): -2
- ("xbin", "xprob", "coupling_strength"): 1
- ("xprob", "xvol", "coupling_strength"): 1
- ("xprob", "initial_mean"): 0
- ("xprob", "initial_precision"): 1
- ("xvol", "initial_mean"): 0
- ("xvol", "initial_precision"): 1HierarchicalGaussianFiltering.premade_continuous_2level — Method
premade_continuous_2level(config::Dict; verbose::Bool = true)The standard 2 level continuous HGF, which filters a continuous input. It has a continous input node u, with a single value parent x, which in turn has a single volatility parent xvol.
Config defaults:
- ("u", "input_noise"): -2
- ("x", "volatility"): -2
- ("xvol", "volatility"): -2
- ("u", "x", "coupling_strength"): 1
- ("x", "xvol", "coupling_strength"): 1
- ("x", "initial_mean"): 0
- ("x", "initial_precision"): 1
- ("xvol", "initial_mean"): 0
- ("xvol", "initial_precision"): 1
HierarchicalGaussianFiltering.premade_hgf — Function
premade_hgf(model_name::String, config::Dict = Dict(); verbose = true)Create an HGF from the list of premade HGFs.
Arguments
- 'model_name::String': Name of the premade HGF. Returns a list of possible model names if set to 'help'.
- 'config::Dict = Dict()': A dictionary with configurations for the HGF, like parameters and settings.
- 'verbose::Bool = true': If set to false, warnings are hidden.
HierarchicalGaussianFiltering.update_hgf! — Method
update_hgf!(
hgf::HGF,
inputs::Union{
Real,
Missing,
Vector{<:Union{Real,Missing}},
Dict{String,<:Union{Real,Missing}},
},
)Update all nodes in an HGF based on an input. The input can either be missing, a single value, a vector of values, or a dictionary of input node names and corresponding values.
HierarchicalGaussianFiltering.update_node_input! — Method
update_node_input!(node::AbstractInputNode, input::Union{Real,Missing})Update the prediction of a single input node.
HierarchicalGaussianFiltering.update_node_posterior! — Method
update_node_posterior!(node::AbstractStateNode; update_type::HGFUpdateType)Update the posterior of a single continuous state node. This is the classic HGF update.
HierarchicalGaussianFiltering.update_node_posterior! — Method
update_node_posterior!(node::CategoricalStateNode)Update the posterior of a single categorical state node.
HierarchicalGaussianFiltering.update_node_posterior! — Method
update_node_posterior!(node::AbstractStateNode; update_type::HGFUpdateType)Update the posterior of a single continuous state node. This is the classic HGF update.
HierarchicalGaussianFiltering.update_node_posterior! — Method
update_node_posterior!(node::AbstractStateNode)Update the posterior of a single continuous state node. This is the enahnced HGF update.
HierarchicalGaussianFiltering.update_node_posterior! — Method
update_node_posterior!(node::AbstractStateNode, update_type::UnboundedUpdate)Update the posterior of a single continuous state node. This is the unbounded HGF update (Mathys et al., 2026), which guarantees a positive posterior precision for volatility parents.
HierarchicalGaussianFiltering.update_node_precision_prediction_error! — Method
update_node_precision_prediction_error!(node::BinaryInputNode)There is no volatility prediction error update for binary input nodes.
HierarchicalGaussianFiltering.update_node_precision_prediction_error! — Method
update_node_precision_prediction_error!(node::BinaryStateNode)There is no volatility prediction error update for binary state nodes.
HierarchicalGaussianFiltering.update_node_precision_prediction_error! — Method
update_node_precision_prediction_error!(node::CategoricalInputNode)There is no volatility prediction error update for categorical input nodes.
HierarchicalGaussianFiltering.update_node_precision_prediction_error! — Method
update_node_precision_prediction_error!(node::CategoricalStateNode)There is no volatility prediction error update for categorical state nodes.
HierarchicalGaussianFiltering.update_node_precision_prediction_error! — Method
update_node_precision_prediction_error!(node::AbstractInputNode)Update the value prediction error of a single input node.
HierarchicalGaussianFiltering.update_node_precision_prediction_error! — Method
update_node_precision_prediction_error!(node::AbstractStateNode)Update the volatility prediction error of a single state node.
HierarchicalGaussianFiltering.update_node_prediction! — Method
update_node_prediction!(node::BinaryInputNode)There is no prediction update for binary input nodes, as the prediction precision is constant.
HierarchicalGaussianFiltering.update_node_prediction! — Method
update_node_prediction!(node::BinaryStateNode)Update the prediction of a single binary state node.
HierarchicalGaussianFiltering.update_node_prediction! — Method
update_node_prediction!(node::CategoricalInputNode)There is no prediction update for categorical input nodes, as the prediction precision is constant.
HierarchicalGaussianFiltering.update_node_prediction! — Method
update_node_prediction!(node::CategoricalStateNode)Update the prediction of a single categorical state node.
HierarchicalGaussianFiltering.update_node_prediction! — Method
update_node_prediction!(node::AbstractInputNode)Update the posterior of a single input node.
HierarchicalGaussianFiltering.update_node_prediction! — Method
update_node_prediction!(node::ContinuousStateNode)Update the prediction of a single state node.
HierarchicalGaussianFiltering.update_node_value_prediction_error! — Method
update_node_value_prediction_error!(node::BinaryInputNode)Update the value prediction error of a single binary input node.
HierarchicalGaussianFiltering.update_node_value_prediction_error! — Method
update_node_value_prediction_error!(node::AbstractStateNode)Update the value prediction error of a single state node.
HierarchicalGaussianFiltering.update_node_value_prediction_error! — Method
update_node_value_prediction_error!(node::CategoricalInputNode)
There is no value prediction error update for categorical input nodes.HierarchicalGaussianFiltering.update_node_value_prediction_error! — Method
update_node_value_prediction_error!(node::AbstractStateNode)Update the value prediction error of a single state node.
HierarchicalGaussianFiltering.update_node_value_prediction_error! — Method
update_node_value_prediction_error!(node::AbstractInputNode)Update the value prediction error of a single input node.
HierarchicalGaussianFiltering.update_node_value_prediction_error! — Method
update_node_value_prediction_error!(node::AbstractStateNode)Update the value prediction error of a single state node.
This page was generated using Literate.jl.