Exploring active inference by building toy models on SPM12's spm_ADEM solver.
- macOS with Homebrew
- GNU Octave:
brew install octave
Reproduces Friston et al. 2015 - "Knowing one's place: a free-energy approach to pattern regulation". 16 cells start at identical positions and self-assemble into a target morphology (head-body-tail) over 32 time steps using free energy minimization.
octave --gui run_morphogenesis.mAn agent expends energy and observes what comes back: reward (diminishing returns) and fatigue (quadratic cost). It maintains core beliefs about self-efficacy — "effort pays off," "moderate returns," or "effort is futile" — that shape how much energy it expends, which shapes what it observes, which reinforces the beliefs.
Same generative process, same model structure, different precision balance:
- Healthy: loose prior, high sensory precision — beliefs update from evidence, agent converges to moderate effort
- Depressed: rigid prior toward "effort is futile," low sensory precision — low effort produces low reward, confirming the belief
- Manic: rigid prior toward "effort always pays off," low sensory precision — high effort hits diminishing returns, but prediction errors are ignored
octave --gui run_psychology.mSee psychology.md for the full model description.
Interactive browser interface for the psychology model. Lets you pick presets (Healthy, Depressed, Manic) or tweak parameters with sliders, and streams simulation results as real-time charts.
Requires Node.js and GNU Octave.
# Terminal 1: start the server (runs Octave in the background)
cd web/server
npm install
npm run dev
# Terminal 2: start the client
cd web/client
npm install
npm run devThen open http://localhost:5173.
- Architecture - How the SPM12 library and custom model code interact
- Experiments - Modeling log: beliefs, interventions, outcomes, and next steps
spm12/spm_platform.mwas patched to support Apple Silicon (arm64)- SPM12 source: https://github.com/spm/spm12