Series: The Learn Arc — 50 posts teaching Active Inference through a live BEAM-native workbench. ← Part 23: Session 4.1. This is Part 24.
The session
Chapter 4, §2. Session title: The A matrix. Route: /learn/session/4/s2_a_matrix.
You have your three lists. Now you write the first matrix. A is P(o | s) — the sensor model, the likelihood term, the place perception lives in an Active Inference agent. Every belief update (Eq. 4.13) reaches into A at least once per tick.
The shape
A is a column-stochastic matrix with:
- Rows indexed by observation values (
|o|). - Columns indexed by hidden states (
|s|). - Each column sums to 1 (
Σ_o P(o | s) = 1for every s).
For the tiny corridor with 4 states and 4 observation values:
s=L s=M1 s=M2 s=R
o=W00 0.94 0.02 0.02 0.02
o=W01 0.02 0.94 0.02 0.02
o=W10 0.02 0.02 0.94 0.02
o=W11 0.02 0.02 0.02 0.94
The 0.94 on the diagonal is "if you're in state L, you'll see wall-signature W00 94% of the time." The 0.02 off-diagonals are sensor noise — 2% chance of any given confusion. Columns sum to 1.
Three flavors of A
Session 4.2 surveys three ways to fill A:
1. Deterministic A. All diagonal mass, no off-diagonal noise. P(o|s) is a permutation matrix. The sensor always tells the truth. Fastest to compute, easiest to reason about, unrealistic for anything interesting.
2. Noisy A. Diagonal dominant with small off-diagonal mass. The sensor usually tells the truth but occasionally lies. This is the classic POMDP setup and the most common case in the literature. Tiny corridor uses this.
3. Dirichlet-learned A. The agent starts with a prior over A and updates the prior as it observes (state, obs) pairs. The conjugate updater is a simple count-addition; Eq. 7.10 makes it precise. Chapter 7 is where this gets its own lesson; Session 4.2 flags it.
How A shows up in the belief update
Eq. 4.13 for a single time step, with all the message-passing stuff abstracted away:
q(s_τ) ∝ exp( log A[o_τ, s_τ] + ... )
The log A[o_τ, s_τ] term is the likelihood message. When the agent observes o_τ, it looks up column s_τ of A (for each candidate state) and adds the log-probability of that column's row for o_τ. That's literally the perception step.
Precision on this likelihood term is what Chapter 5 maps to acetylcholine. High ACh = high precision on A = sensor-driven beliefs. Low ACh = low precision = prior-dominant beliefs. The clinical signatures are startlingly specific.
Noise tuning
/cookbook/perception-noisy-sensor-robustness is the recipe that sweeps A's off-diagonal mass across an order of magnitude. Watch the agent's behavior shift:
- Very noisy (off-diagonal 0.25) — agent's belief heatmap stays diffuse even after many ticks. Actions are uncertain.
- Moderately noisy (off-diagonal 0.05) — belief sharpens in 3–5 ticks. Agent converges on the right plan.
- Clean (off-diagonal 0.001) — one observation pinpoints the state. Agent acts almost deterministically after 1 tick.
The recipe's UI shows all three side by side. You watch the noise/convergence trade-off directly.
The factored A
One extension worth mentioning: in factored observation spaces (multiple modalities), you have one A matrix per modality. The belief update sums log-likelihoods across modalities:
q(s_τ) ∝ exp( Σ_m log A_m[o_{τ,m}, s_τ] + ... )
This is how a multimodal agent (vision + audio + touch) composes its likelihoods. Each modality contributes one matrix; the log-sum is the total evidence from that tick. /cookbook/multimodal-cue-combination exercises this with two modalities.
The wall-signature recipe
/cookbook/perception-wall-signature-localisation is a direct demonstration: in the tiny-corridor world, walls are the distinguishing observations. An agent with a well-calibrated A can localize itself in under 3 ticks by looking at which walls it sees. With a mis-specified A, it can't. You see the A matrix rendered in the recipe card.
The concepts this session surfaces
-
A matrix —
P(o|s), column-stochastic. - Likelihood — the evidence term in Bayes' rule.
- Sensor noise — off-diagonal mass in A.
- Factored observation — one A per modality.
The quiz
Q: An agent has a crisply-diagonal A but its belief heatmap stays diffuse after many ticks. What's wrong?
- ☐ The A matrix is mis-specified.
- ☐ The agent isn't actually receiving observations; the world is silent. ✓
- ☐ The softmax temperature is too high.
- ☐ The Dirichlet prior is too strong.
Why: A crisply-diagonal A means every observation should pin down the state. If beliefs stay diffuse anyway, the agent isn't getting useful evidence — the world isn't emitting observations that discriminate between states. Check the data pipeline before you blame A.
Run it yourself
-
/learn/session/4/s2_a_matrix— session page. -
/cookbook/perception-noisy-sensor-robustness— noise sweep. -
/cookbook/perception-wall-signature-localisation— A in action. -
/cookbook/multimodal-cue-combination— factored A. -
/cookbook/dirichlet-learn-a-matrix— learned A. -
/equations/eq_4_13_state_belief_update— Eq. 4.13 with A highlighted.
The mental move
A matrix is where the agent's model of the world meets the sensor's raw bits. When perception goes wrong, A is the first thing to check. When the agent is over- or under-confident, A's precision is the knob. Every practical Active Inference debugging session starts here.
Next
Part 25: Session §4.3 — Expected Free Energy, introduced concretely. Chapter 4's third session takes Chapter 3's abstract G(π) and shows how the A and C matrices you now have let you compute it. The bridge between Chapter 3's theory and Chapter 4's running engine.
⭐ Repo: github.com/TMDLRG/TheORCHESTRATEActiveInferenceWorkbench · MIT license
📖 Active Inference, Parr, Pezzulo, Friston — MIT Press 2022, CC BY-NC-ND: mitpress.mit.edu/9780262045353/active-inference
← Part 23: Session 4.1 · Part 24: Session 4.2 (this post) · Part 25: Session 4.3 → coming soon

Top comments (0)