// readme

PyHGF is a Python library for creating and manipulating dynamic probabilistic networks for predictive coding. These networks approximate Bayesian inference by optimising beliefs through the diffusion of predictions and precision-weighted prediction errors. The graph structure remains flexible during message-passing steps, allowing for dynamic adjustments. They can be used as a biologically plausible cognitive model in computational neuroscience or as a generalisation of Bayesian filtering for designing efficient, modular decision-making agents. With the current version you can:

  • Build arbitrarily sized networks with the generalised Hierarchical Gaussian Filters (Weber et al., 2026)
  • Use generalised Bayesian filtering with distributions from the exponential family (Mathys & Weber, 2020)
  • Define custom planning and action selection functions throught trajectories sampling (e.g. sophisticated inference, Friston et al., 2020)
  • Learn in deep predictive coding networks using a fast and scalable rethinking of prospective configuration…