For a list of all posts go here.
Abstract
Active Inference models biological agents as self-organizing systems that maintain structural integrity by minimizing Variational Free Energy (VFE). This paper explores the epistemological and mechanical boundaries between physical ground-truth reality and an agent’s internal subjective reconstruction. We implement an online Predictive Coding Neural Network (PCNN) navigating an environment containing dynamic target attractors and localized threat obstacles. Critically, we examine the behavioral and affective distortions—termed here "cognitive illusions"—that arise when an agent's top-down generative weights are miscalibrated or non-optimal.
Furthermore, we formalize an emotional mapping layer where affective valence is modeled as the second-order rate of change of VFE. Our empirical results, derived from continuous time-series simulation logs across 2,480 iterations, reveal that mismatched weights induce stable spatial tracking offsets that prematurely paralyze the agent. When online synaptic plasticity is re-engaged via gradient descent on the Neural Network VFE, the agent dynamically re-calibrates its generative model. This structural learning process reduces subjective free energy by over 99.5%, collapses the perceptual divergence, triggers predictable transitions in emotional states from anxiety to homeostatic motivation, and restores objective goal tracking.
1. Introduction
A foundational premise of theoretical biology and computational neuroscience is that living organisms must resist the natural tendency toward thermodynamic decay and informational entropy. Active Inference, formalized via the Free Energy Principle (FEP), posits that agents achieve this existential imperative by executing actions that minimize an upper bound on sensory surprise, known as Variational Free Energy (VFE). Under this paradigm, the brain does not passively register environmental impressions; instead, it operates as a hierarchical prediction engine, constantly projecting top-down hypotheses about the hidden causes of its sensory streams.
However, a deep conceptual vulnerability emerges when an agent's internal map of the world—its generative model—diverges structurally from the actual laws governing the environment—the generative process. If the internal synaptic pathways that translate beliefs into expected sensations are miscalibrated, the agent’s perceptual apparatus will distort reality.
While existing literature frequently evaluates Active Inference under idealized, perfectly matched models, this paper systematically investigates the mechanics of model miscalibration. We decouple physical ground-truth coordinates from internal network beliefs to study three interconnected phenomena:
The temporal alignment between physical trajectories and inferred beliefs under an asymmetric sensory integration architecture.
The genesis of stable spatial "cognitive illusions" driven by non-optimal generative weights.
The mathematical and empirical divergence between the true analytical free energy of the environment and the subjective free energy computed by the agent’s neural architecture.
The formal computational modeling of affective valence and emotional states as a reflection of the second-order rate of change of free energy over time.
By analyzing the comprehensive data profiles of an active inference agent across 2,480 iterations of simulated environmental interaction, we chart the exact journey of an uncalibrated mind discovering, suffering from, and ultimately resolving its own structural illusions through synaptic learning.
2. Mathematical Foundations & Generative Architecture
To mathematically parse the boundary between objective nature and subjective mind, we establish a rigid dual-space architecture.
2.1 The Generative Process (Physical Reality)
Let (1) define the absolute, omniscient ground-truth coordinates of the physical agent in a bounded two-dimensional arena. The agent moves through space based on an applied physical velocity vector v actual (2).
The environment contains a static target attractor and a localized threat obstacle. The agent possesses no direct, unmediated access to its ground-truth coordinates. It must observe itself through a noisy sensory channel (3), where (4) represents high-frequency environmental and sensory measurement noise.
2.2 The Generative Model (Subjective Neural Network)
The agent possesses an internal network parameterized by internal state beliefs (5) and top-down generative weights (6). The network's sensory prediction is defined as (7)
When the agent can perceive environmental features (governed by visibility thresholds), it computes sensory prediction errors. The total spatial prediction error (11) is divided into target-directed attraction (9) and threat-directed repulsion (10) components, weighted by their respective sensory precisions (8).
The system’s Variational Free Energy is mathematically represented as the squared sum of these precision-weighted prediction errors (12).
Action in Active Inference proceeds via the changing of states to fulfill predictions. The motor velocity command executed by the physical body is driven directly by the reflex-like minimization of this error gradient (13).
3. Core Structural Analyses
3.1 Ground Truth Trajectory vs. Inferred Belief State
A critical development in our model involves how the agent integrates time. The agent updates its subjective position belief by adding its internal inferred velocity command (14).
Our refined architecture enforces strict asymmetric sensory integration. The internal states (5) are determined strictly by filtering incoming observations. As demonstrated in the empirical logs, the inferred belief trail binds tightly to the ground-truth trajectory. The belief state hovers directly over the physical agent, experiencing only a high-frequency jitter bounded directly by the sensory noise variance (4).
Figure 1: Perceptual Trajectory Tracking Map
Caption: Figure 1: Spatial trajectory mapping within the agent´s arena. The solid blue line tracks the physical agent's ground-truth path, while the dotted trail tracks the internal self-belief state.
3.2 Cognitive Illusions Induced by Non-Optimal Weights
When the generative weights are frozen away from unity, the network experiences a profound cognitive distortion. We simulated this state by initializing weights at (15)
Under these non-optimal weights, the agent develops a structural blind spot. As it approaches the target, its internal network calculates that it has arrived at the correct position, because the distorted top-down prediction perfectly cancels out the incoming sensory observations (16). Subjectively, the agent believes its free energy is minimized, causing its motor commands to ramp down to zero. Objectively, however, the agent is paralyzed several units away from the target star, frozen in space by an uncorrected perceptual bias.
3.3 Analytical VFE vs. Neural Network VFE Profiles
To map this discrepancy, we track two distinct energy metrics:
Analytical VFE: The absolute error function calculated using omniscient ground-truth coordinates.
Neural Network VFE: The internal error calculated strictly through the agent's distorted generative model (17).
When weights are static and non-optimal, Neural Network VFE drops to zero as the agent experiences its illusion of arrival, while Analytical VFE remains high. This divergence proves that an agent can optimize its internal universe perfectly while remaining completely uncalibrated with the physical world.
To bridge this gap, we re-engage synaptic plasticity by allowing the prediction error to flow back into the weights via online gradient descent (18), (19) e (20):
Under this configuration, the lingering prediction error actively rewires the network's parameters (as seen in Figure 1´s right graphic) as the agent sits for a moment in its illusion zone, before converging to the target´s true position.
3.4 Mathematical Formalization of Affective Valence (Emotional States)
Following the mathematical models of Smith, Friston, and Kirsch (2019), we formalize the agent's emotional state as the second-order rate of change of free energy over time. Let (21) define the emotional valence metric:
We map three explicit computational thresholds based on the dynamics of (21) and the presence of contextual precision indicators:
Epistemic Exploration / Curiosity: Occurs when VFE is flat or gently fluctuating near zero under low contextual precision. The agent experiences low error gradients and engages in unconstrained search.
Threat Repulsion / Anxiety: Characterized by highly unpredictable, positive acceleration spikes in VFE paired with high-precision threat inputs. The agent registers a rapid expansion of surprise, manifesting behaviorally as avoidant repulsion.
Target Attractor Lock / Motivation: Initiated when VFE begins dropping significantly faster than a baseline expectation. The rapid minimization of prediction error yields positive emotional valence, driving sustained, focused motor action until satiation homeostasis (VFE approaches 0, (21) approaches 0) is achieved.
4. Empirical Results & Data-Driven Discussion
The model was evaluated over a continuous run of 2,480 iterations. Telemetry logs captured the exact behavioral and emotional state transitions of the agent, divided across three distinct phases.
4.1 Phase 1: Epistemic Foraging (66.73% of Lifetime)
For the first 1,655 steps, the agent was placed outside the visibility horizon of both the target and the threat. Operating under zero environmental information, the system engaged in epistemic exploration. The physical coordinates moved via a bounded random walk, search-foraging through the environment. The logs recorded this baseline state as "Epistemic Exploration. I am curious.". Because spatial prediction errors were absent outside visibility zones, the weights remained unchanged at their initial values.
4.2 Phase 2: Threat Repulsion and Anxiety (18.27% of Lifetime)
During its random walk, the agent repeatedly breached the perimeter of the threat zone. Entering this sector triggered an immediate spike in precision-weighted threat prediction errors, causing the free energy to rise sharply.
The system logged this state as "Threat Repulsion. I am anxious.". This computational anxiety generated a powerful repulsive motor command vector that successfully drove the agent out of harm's way, illustrating how affective valences function as rapid protective mechanisms in cybernetic systems.
4.3 Phase 3: Attractor Lock and Plasticity Convergence (15.00% of Lifetime)
At iteration 2,108, the agent crossed the visibility threshold of the target. It moved forward but halted prematurely due to its weight-induced illusion. At step 2,108, the weights stood heavily biased, causing an internal network loss of 1.9858 .
As the agent stagnated, online synaptic plasticity began resolving the mismatch. The prediction errors actively re-tuned the synaptic paths over the remaining 372 steps of the simulation.
Simulation Step |
Weight X |
Weight Y |
Neural Net VFE |
Physical X |
Physical Y |
Affective Mood State |
|---|---|---|---|---|---|---|
2,108 (Target Encounter) |
1.2615 |
0.8135 |
1.9858 |
1.5933 |
6.2920 |
Target Lock. I feel motivated. |
2,115 (Learning Intercept) |
1.2793 |
0.8430 |
0.6771 |
2.1104 |
6.8410 |
Target Lock. I feel motivated. |
2,470 (Near Convergence) |
1.0001 |
1.0008 |
0.0174 |
8.0095 |
7.9972 |
Target Lock. I feel motivated. |
2,479 (Satiation Homeostasis) |
1.0006 |
1.0008 |
0.0102 |
8.0053 |
8.0012 |
Target Lock. I feel motivated. |
As shown in the data table, the gradient descent update pulled both weights back to near-unity. As the internal structural map aligned with reality, the internal network loss plummeted by 99.48%, dropping from 1.9858 to a baseline of 0.0102 .
Because the free energy was dropping consistently faster than the baseline expectations, the system sustained its high-motivation valence ("Target Attractor Lock. I feel motivated."). With its perceptual illusion dissolved, the agent resumed its trajectory, executing accurate motor commands that brought its physical body to rest directly on the true target coordinates, achieving full homeostatic stability and emotional satiation.
Figure 2: Synaptic Weight and Free Energy Convergence Profile
Caption: Figure 2: Multi-panel time-series analysis of the phase-three learning intercept. The top panel illustrates the dynamic adaptation of generative weights as they converge toward unity (1.0) upon encountering the target at iteration 2,108. The bottom panel displays the matching exponential decay of Variational Free Energy, which drops by over 99.5% as the structural illusion dissolves, maintaining a positive affective motivation state.
5. Conclusion
This paper demonstrates that Active Inference loops are highly vulnerable to systematic spatial offsets and behavioral stagnation when their top-down generative components are miscalibrated. An agent can optimize its internal neural network parameters to experience a subjective illusion of target arrival, while remaining objectively stranded short of its physical destination.
By separating the system into a dual-space architecture—objective physical truth versus subjective inferred belief—we successfully tracked this divergence. Furthermore, by framing emotional states as the second-order rate of change of free energy, we show how cognitive illusions and threats project distinct affective signatures onto the agent's internal state.
Crucially, our results show that introducing online synaptic plasticity driven by prediction errors allows the agent to break its own perceptual illusions. Over time, the network updates its generative weights, aligns its subjective free energy with absolute environmental free energy, and guides the physical chassis to its true target destination.









