  We develop the compositional theory of active inference by introducing
activity, functorially relating statistical games to the dynamical systems
which play them, using the new notion of approximate inference doctrine. In
order to exhibit such functors, we first develop the necessary theory of
dynamical systems, using a generalization of the language of polynomial
functors to supply compositional interfaces of the required types: with the
resulting polynomially indexed categories of coalgebras, we construct monoidal
bicategories of differential and dynamical ``hierarchical inference systems'',
in which approximate inference doctrines have semantics. We then describe
``externally parameterized'' statistical games, and use them to construct two
approximate inference doctrines found in the computational neuroscience
literature, which we call the `Laplace' and the `Hebb-Laplace' doctrines: the
former produces dynamical systems which optimize the posteriors of Gaussian
models; and the latter produces systems which additionally optimize the
parameters (or `weights') which determine their predictions.
