Academic Editor: Astero Provata
Received: 25 October 2024
Revised: 2 January 2025
Accepted: 7 January 2025
Published: 12 January 2025
Citation: Nehrer, S.W.; Ehrenreich
Laursen, J.; Heins, C.; Friston, K.;
Mathys, C.; Thestrup Waade, P .
Introducing ActiveInference.jl: A
Julia Library for Simulation and
Parameter Estimation with Active
Inference Models. Entropy 2025, 27, 62.
https://doi.org/10.3390/e27010062
Copyright: © 2025 by the authors.
Licensee MDPI, Basel, Switzerland.
This article is an open access article
distributed under the terms and
conditions of the Creative Commons
Attribution (CC BY) license
(https://creativecommons.org/
licenses/by/4.0/).
Article
Introducing ActiveInference.jl: A Julia Library for Simulation
and Parameter Estimation with Active Inference Models
Samuel William Nehrer 1,†
 , Jonathan Ehrenreich Laursen 1,†
 , Conor Heins 2,3,*
 , Karl Friston 3,4
 ,
Christoph Mathys 5
 and Peter Thestrup Waade 5
1 School of Culture and Communication, Aarhus University, 8000 Aarhus, Denmark;
202204724@post.au.dk (S.W.N.); 202204836@post.au.dk (J.E.L.)
2 Department of Collective Behaviour, Max Planck Institute of Animal Behavior, D-78457 Konstanz, Germany
3 VERSES Research Lab., Los Angeles, CA 90016, USA; k.friston@ucl.ac.uk
4 Queen Square Institute of Neurology, University College London, London WC1N 3BG, UK
5 Interacting Minds Centre, Aarhus University, 8000 Aarhus, Denmark; chmathys@cas.au.dk (C.M.);
ptw@cas.au.dk (P .T.W.)
* Correspondence: cheins@ab.mpg.de
† These authors contributed equally to this work.
Abstract: We introduce a new software package for the Julia programming language,
the library ActiveInference.jl. To make active inference agents with Partially Ob-
servable Markov Decision Process (POMDP) generative models available to the grow-
ing research community using Julia, we re-implemented the pymdp library for Python.
ActiveInference.jl is compatible with cutting-edge Julia libraries designed for cognitive
and behavioural modelling, as it is used in computational psychiatry, cognitive science
and neuroscience. This means that POMDP active inference models can now be easily
fit to empirically observed behaviour using sampling, as well as variational methods. In
this article, we show how ActiveInference.jl makes building POMDP active inference
models straightforward, and how it enables researchers to use them for simulation, as well
as fitting them to data or performing a model comparison.
Keywords: active inference; free energy principle; predictive processing; Markov decision
process; cognitive modelling; Julia
PACS: 87.15.Aa
MSC: 91-08
JEL Classification: C63
1. Introduction
We introduce a novel software library for Julia, ActiveInference, which lets users
produce the simulated behaviour of agents and their internal belief states with active
inference (AIF) models, as well as fit such models to empirically observed behaviour.
AIF [1–3] is a generally applicable formal framework for understanding and simulating
intelligent behaviour that is based in neurobiology and first principles from statistical
physics [4–8]. AIF treats action and perception as unified under a joint imperative: to
minimise the variational free energy (VFE), which quantifies how well the agent’s internal
generative model explains incoming sensory observations. It is an upper bound on the
the surprise from sensory observations, making AIF formally related to prediction error
Entropy 2025, 27, 62 https://doi.org/10.3390/e27010062