Markov and Partially Observable Decision Processes

Michael BrenndoerferJune 7, 202658 min read

Part of World Models Handbook

Explains how MDPs, POMDPs, policies, values, and belief states formalize sequential decisions when dynamics are uncertain and observations hide the true state.

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Markov and Partially Observable Decision Processes

Imagine a small delivery robot navigating an office. It starts near the elevator, must pick up a package from a desk, and deliver it to a reception counter. The floor is slippery in places, the robot's wheel encoders are noisy, and a closed door sometimes hides the counter from view. Every few seconds the robot faces a choice: drive forward, turn, or pause and re-check its surroundings. Some choices lead smoothly to the goal. Others waste energy, or worse, send the robot tumbling down the stairwell at the end of the hall.

Notice how many distinct difficulties are packed into this humble scenario. Uncertainty enters through at least three separate doors: the slippery floor makes the consequences of actions unpredictable, the noisy encoders make the robot unsure where it is, and the closed door hides information about what exists beyond the robot's current line of sight. A useful formalism has to accommodate all three, and, as we will see, it handles them in different ways: stochastic transitions belong to the dynamics, while partial observability demands a deeper change to what "state" even means for the agent. Keeping these sources of uncertainty separate in your mind from the start will make the second half of this chapter much easier to absorb.

This chapter gives you the formal vocabulary for problems like this one. In Part I: The World-Model Idea, we built world models that predict what happens next. Prediction alone, however, does not tell the robot what to do. A perfect forecasting model can tell the robot where each candidate action leads, but it attaches no preference among those futures. To reason about action, we need three additional ingredients: a notion of choice (actions), a notion of desirability (rewards), and a way to score long-term consequences (returns and value functions). The Markov Decision Process, or MDP, packages these ingredients into a formalism that underlies nearly all modern work in sequential decision making. Its partially observable cousin, the POMDP, extends it to the realistic case where the agent never sees the true state of the world.

We will proceed in four steps. First, we define the MDP and examine the Markov assumption that makes it tractable. Second, we develop policies, returns, and value functions, culminating in the Bellman equations and value iteration. Third, we study how the Markov assumption fails and how POMDPs repair the damage with belief states. Finally, we implement both sides: a fully observed gridworld solved by value iteration, and a T-maze experiment showing quantitatively why memory turns a losing agent into a winning one. The material here is the foundation for everything in Part II: Inference, Decisions, and Control: the next chapter, Bayesian Filtering and Belief States, develops the estimation machinery this chapter motivates.

From Prediction to Decisions

This section connects the dynamical systems view from Part I to the decision-making view we need now, and fixes the vocabulary we will use for the rest of the book.

Recall from Mathematical and Dynamical Foundations that a controlled dynamical system evolves according to a state transition rule such as st+1=f(st,at,wt)s_{t+1} = f(s_t, a_t, w_t), where ata_t is a control input and wtw_t is noise. A world model, as we framed it in What Is a World Model?, is essentially a learned version of ff: given the current situation and a candidate action, it predicts what happens next. Nothing in that formulation says whether the action is good, bad, or indifferent. The model is a neutral simulator, and if you hand an agent nothing but a simulator, the best it can do is enumerate futures, not rank them.

Decision making adds a scoring layer. We assume the environment emits a scalar reward after each transition, and the agent's goal is to collect as much cumulative reward as possible over time. This single assumption is remarkably productive: navigation, game playing, resource management, and motor control can all be cast as reward accumulation, and the rest of this chapter is about reasoning precisely with it. It is worth pausing on how strong a simplification this is. Every objective we might care about, whether it is "deliver the package," "minimize energy," or "keep the factory running," gets flattened onto a single number line. That flattening buys enormous mathematical power: comparing any two behavior patterns reduces to comparing two numbers. It also carries risk, since a poorly chosen reward measures something other than what we intended. We return to that danger in the Limitations section; for now, note that the entire machinery ahead takes the reward function as given and asks only how to maximize it.

Because the words state, observation, and action will carry heavy loads, let us fix their meanings now:

  • State (ss): the situation of the environment, including anything that influences its future. The agent may or may not have access to it.
  • Observation (oo): what the agent actually senses. Observations can be incomplete, noisy, or ambiguous about the state.
  • Action (aa): a decision the agent selects, which influences the transition of the state.
  • Transition (PP): the probabilistic rule by which states evolve under actions.
  • Reward (rr): a scalar signal emitted by the environment, treated as given rather than chosen by the agent.
  • Policy (π\pi): the agent's decision rule, mapping whatever it knows to an action.
  • Environment: the process that consumes actions and produces next states, observations, and rewards.

Keeping these roles distinct matters more than it might seem. Much confusion in applied work comes from blurring state with observation, or from treating a learned latent representation as if it were the environment state. For example, when a neural network compresses camera frames into a latent vector, it is tempting to call that vector "the state." Whether it deserves the name depends entirely on whether it preserves everything relevant to the future, which is precisely the question the Markov property will let us pose precisely. We will return to that distinction repeatedly.

The Markov Decision Process

This section defines the MDP formally, states the Markov assumption, and explains discounting and horizons. Everything later in the book, from Kalman filters to large-scale world models, is best read as a variation on this template.

Definition: Markov Decision Process

A Markov Decision Process is a tuple M=(S,A,P,R,γ,ρ0)\mathcal{M} = (\mathcal{S}, \mathcal{A}, P, R, \gamma, \rho_0) where:

  • S\mathcal{S} is the set of states,
  • A\mathcal{A} is the set of actions,
  • P(s′∣s,a)P(s' \mid s, a) is the transition kernel, the probability of landing in state s′s' after taking action aa in state ss,
  • R(s,a,s′)R(s, a, s') is the reward function, the reward received when a transition from ss to s′s' occurs under action aa,
  • γ∈[0,1)\gamma \in [0, 1) is the discount factor,
  • ρ0\rho_0 is the distribution over initial states.

Each element answers a distinct question, and it helps to read the tuple that way. The state space S\mathcal{S} and initial distribution ρ0\rho_0 describe where the story can begin. The action set A\mathcal{A} describes what the agent can influence. The transition kernel PP describes how the world responds, capturing both physics and noise in a single conditional distribution. The reward function RR describes what matters, translating each transition into a score. Finally, the discount factor γ\gamma describes how patient the agent is, a quantity whose full meaning emerges below. If you can locate all six pieces for a concrete problem, you have turned an informal description into a solvable decision problem.

The transition kernel is the world model in miniature: it answers the predictive question "if we do aa here, where do we end up?" The reward function answers the evaluative question "how much did that outcome help?" Notice the deliberate division of labor between the two: prediction is descriptive, evaluation is normative, and neither substitutes for the other. A fully specified MDP is therefore a complete decision problem, and much of this book is about learning or approximating its pieces from data. Later chapters differ mainly in which piece they learn and how they plan against the learned version, while the skeleton of the problem stays exactly as written above.

The Markov Property and Why Everything Depends on It

The adjective Markov refers to one assumption that does an enormous amount of work.

Definition: Markov Property

A state sts_t is Markov with respect to a process if it summarizes all relevant history:

P(st+1∣st,at,ht)=P(st+1∣st,at),P(s_{t+1} \mid s_t, a_t, h_t) = P(s_{t+1} \mid s_t, a_t),

where ht=(o0,a0,o1,a1,…,ot)h_t = (o_0, a_0, o_1, a_1, \ldots, o_t) is everything the agent has seen so far. Given the present state and action, the past provides no additional predictive power.

Why does this matter so much? Because it collapses an ever-growing history into a fixed-size summary. Without it, every quantity of interest would be indexed by a history hth_t. At a fixed finite horizon, the history set is finite but grows exponentially whenever actions or observations branch. With an unbounded horizon, individual histories also grow without bound, so there is no fixed finite history table or fixed-size per-state recursion. Under the Markov property, by contrast, a policy only needs the current state, transition probabilities only need the current state and action, and the mathematics of planning becomes recursive rather than historical. Every efficient algorithm in this book, from value iteration to Kalman filtering to latent dynamics models, exploits some version of this compression.

It is worth being precise about what the Markov property does not claim. It does not claim the world is deterministic, nor that it is noiseless, nor even that the state is small. Stochasticity survives fully intact inside P(s′∣s,a)P(s' \mid s, a); the property constrains what the probabilities condition on, not how random they are. Nor does it claim the agent's chosen representation is automatically adequate. It claims only that the chosen state representation is predictively sufficient: no information relevant to the future is missing from it. Whether a given representation satisfies this is an empirical property of the environment paired with the representation, and Section "When the Markov Assumption Fails" examines what happens when it does not hold.

There is also a constructive reading worth internalizing: the Markov property is something you can often engineer. If position alone fails to predict next position, include velocity; if velocity fails, include acceleration; if battery charge matters, measure it. Each enrichment costs dimensionality, so practical modeling is a negotiation between sufficiency and tractability. That negotiation recurs throughout this book wherever learned latent representations stand in for engineered features.

Assumptions in Play

From here on we implicitly assume:

  • Markov dynamics: the state summarizes the past, as defined above.
  • Stationarity: PP and RR do not change over time.
  • Full observability: the agent perceives the true state, so ot=sto_t = s_t. We relax this later in the chapter.
  • Tabular scope: the theorem statements and algorithms in the MDP treatment use finite discrete state and action spaces with bounded rewards.
  • Known model versus sampled experience: the mathematics below assumes PP and RR are known. In practice we often only have samples, which is the subject of System Identification and model-based reinforcement learning.

Rewards, Returns, and Discounting

The agent does not care about individual rewards so much as about their accumulated total. The quantity of interest is the return GtG_t, the total discounted reward from time tt onward:

Gt=∑k=0∞γkrt+k.G_t = \sum_{k=0}^{\infty} \gamma^k r_{t+k}.

For episodic tasks that terminate, such as our delivery robot finishing its route, the sum simply stops at the terminal time step. For continuing tasks that never end, the discount factor γ\gamma serves two purposes at once, and understanding both prevents a lot of confusion.

First, γ\gamma is an economic preference for earlier reward. With γ=0.9\gamma = 0.9, a reward arriving ten steps from now counts about 0.910≈0.350.9^{10} \approx 0.35 as much as the same reward today. This mirrors interest rates and time preferences in economics, and in many applications it encodes the fact that sooner is better: energy spent today cannot be reclaimed by reward promised tomorrow. Second, and more technically, γ\gamma guarantees that the infinite sum stays finite and that the optimization problem is well posed. As long as rewards are bounded and γ<1\gamma < 1, the return is bounded by rmax⁡/(1−γ)r_{\max}/(1-\gamma). Without this guarantee, summing rewards forever could diverge, and two infinite quantities could not be compared; with it, every policy receives a finite score and there is always a well-defined best one to seek.

The quantity 1/(1−γ)1/(1-\gamma) is called the effective horizon: it measures how many future steps materially influence decisions. With γ=0.9\gamma = 0.9 the effective horizon is 10 steps; with γ=0.99\gamma = 0.99 it is 100. Choosing γ\gamma is therefore not a numerical detail but a modeling statement about how far ahead the agent should reason. Set it too low and a greedy agent will happily sprint toward a pit because tomorrow's catastrophe is discounted away; set it too high and planning becomes computationally expensive and statistically fragile, since values then depend on chains of many uncertain predictions. We will see in the value iteration experiments that γ\gamma bounds the worst-case contraction rate of Bellman backups, while the transition structure can make actual convergence substantially faster. It therefore sits at the junction of modeling intent and algorithmic cost.

The abstract discussion of discounting becomes much clearer when drawn. The next figure shows how much a unit of reward is worth as a function of how far in the future it arrives, for several values of γ\gamma.

In[3]:
Code
import matplotlib.pyplot as plt
import numpy as np

ks = np.arange(0, 51)
gammas = [0.5, 0.9, 0.99]
discount_curves = {g: g**ks for g in gammas}
effective_horizons = {g: 1.0 / (1.0 - g) for g in gammas}
Out[4]:
Visualization
Log-scale decay curves of discounted reward weight for three gamma values.
Discount weight of a unit reward arriving k steps in the future for gamma = 0.5, 0.9, and 0.99. Larger gamma flattens the curve, extending the effective horizon.

Each curve is a straight line on the logarithmic axis because γk\gamma^k decays geometrically, and its slope is set entirely by γ\gamma. The labeled effective horizons make the modeling statement explicit: moving from γ=0.9\gamma = 0.9 to γ=0.99\gamma = 0.99 stretches the decision-relevant future from ten steps to one hundred.

Two variations round out the picture. In finite-horizon problems, the agent optimizes reward over exactly HH remaining steps; the optimal policy then generally depends on the countdown, so it is nonstationary even in a stationary environment. Intuitively, with ten steps left it pays to take a shortcut you would refuse with three steps left, because there will be time to recover from it. In the average-reward formulation, the agent maximizes reward per step in the long run, which suits some scheduling and queueing problems where no natural notion of "early versus late" exists. Discounted infinite-horizon formulations dominate practice because their theory is especially clean, and we use one for the tabular MDP and value-iteration treatment below. The later T-maze is instead a finite, undiscounted episode.

Policies and Value Functions

This section defines what an agent's decision rule looks like, how to score it, and how the famous Bellman equations turn long-horizon scoring into a one-step recursion.

A policy π\pi is the agent's decision rule. Formally, π(a∣s)\pi(a \mid s) is the probability of choosing action aa in state ss. Deterministic policies are the special case where one action gets probability one. A remarkable fact simplifies everything that follows: for a discounted MDP, if an optimal policy exists, a stationary deterministic optimal policy exists. You never need to remember the past or randomize to act optimally in a fully observed, discounted MDP. Partial observability changes the state on which that result operates: memory becomes necessary when the latest observation underdetermines the latent state, so history must be compressed into a belief. Once the belief is treated as the state, an unconstrained expected-return optimum can again be chosen deterministically. Randomization can still be useful for a deliberately restricted reactive controller, or under fairness, risk, or exploration constraints: when one observation aliases two latent states needing opposite actions, mixing can spread state-conditional regret instead of always sacrificing the same case, though it does not beat the best deterministic action for ordinary expected return at a fixed belief. The T-maze experiment will make the memory distinction measurable.

Value Functions for a Fixed Policy

Given a policy, we can ask how good it is to be in a particular state, assuming the agent follows π\pi forever after. This is the state-value function:

vπ(s)=Eπ ⁣[ Gt∣st=s ].v^\pi(s) = \mathbb{E}_{\pi}\!\left[\, G_t \mid s_t = s \,\right].

Similarly, the action-value function scores taking a specific action first and following π\pi afterward:

qπ(s,a)=Eπ ⁣[ Gt∣st=s, at=a ].q^\pi(s, a) = \mathbb{E}_{\pi}\!\left[\, G_t \mid s_t = s,\ a_t = a \,\right].

The difference qπ(s,a)−vπ(s)q^\pi(s,a) - v^\pi(s) is the advantage of action aa over the policy's own average behavior in ss, a quantity that becomes central when we reach policy improvement and actor-critic methods much later in the book. Positive advantage means the action beats the policy's habit in that state and the policy should lean toward it; negative advantage means the action drags the expected return down.

Notice what these definitions accomplish: they convert a long-run, stochastic question ("what will your total reward be?") into a function of the current situation. That is exactly the compression the Markov property licensed. All of the uncertainty about future slips, future rewards, and future choices collapses into a single expected number attached to each state. A value function is, in effect, a decision-oriented projection of the world model: it folds the transition kernel, the reward function, and the policy into a single number per state. Two environments with wildly different physics can share identical value functions over some region, and conversely tiny changes in PP can move values dramatically. Values summarize consequences, not mechanisms.

The Bellman Equations

The magic of the Markov property is that expectations over infinite futures satisfy one-step recursions. Conditioning on the first transition and applying the law of total expectation gives the Bellman expectation equation for a fixed policy:

vπ(s)=∑aπ(a∣s)∑s′P(s′∣s,a)[ R(s,a,s′)+γ vπ(s′) ].v^\pi(s) = \sum_{a} \pi(a \mid s) \sum_{s'} P(s' \mid s, a)\Big[\, R(s, a, s') + \gamma\, v^\pi(s') \,\Big].

Read it from the inside out: take action aa, land somewhere with probability P(s′∣s,a)P(s' \mid s, a), collect the immediate reward R(s,a,s′)R(s,a,s'), and then be worth vπ(s′)v^\pi(s') in the new state, discounted once. The discount appears once per step, matching the definition of the return, and the outer average over actions weights the policy's own choice habits. The same structure holds for action values:

qπ(s,a)=∑s′P(s′∣s,a)[ R(s,a,s′)+γ∑a′π(a′∣s′) qπ(s′,a′) ].q^\pi(s, a) = \sum_{s'} P(s' \mid s, a)\Big[\, R(s, a, s') + \gamma \sum_{a'} \pi(a' \mid s')\, q^\pi(s', a') \,\Big].

These are linear systems in the unknown values, which means a fixed policy can be evaluated exactly by solving linear equations in small problems, or by iterative averaging in large ones. The recursivity itself deserves emphasis: an expectation involving infinitely many future decisions has been reduced to an equation involving only immediate quantities plus values one step ahead. Every family of algorithms you will meet, dynamic programming, temporal-difference learning, and the Bellman-consistency losses used to train modern world-model agents, is a strategy for solving equations of this shape.

Optimal Values and Value Iteration

For decision making we want the best achievable value, not the value of a given policy. The Bellman optimality equation replaces the policy average with a maximum:

v∗(s)=max⁡a∑s′P(s′∣s,a)[ R(s,a,s′)+γ v∗(s′) ].v^*(s) = \max_{a} \sum_{s'} P(s' \mid s, a)\Big[\, R(s, a, s') + \gamma\, v^*(s') \,\Big].

That one-symbol change, average to maximum, transforms evaluation into optimization: instead of asking what a fixed habit achieves, the equation asks what the best single choice at each state achieves, assuming the same standard applies everywhere downstream. Collect the right-hand side into an operator T\mathcal{T} acting on any value function vv:

(Tv)(s)=max⁡a∑s′P(s′∣s,a)[ R(s,a,s′)+γ v(s′) ].(\mathcal{T}v)(s) = \max_{a} \sum_{s'} P(s' \mid s, a)\big[\, R(s, a, s') + \gamma\, v(s') \,\big].

The key property of T\mathcal{T} is that it is a contraction in the maximum norm. For any two value functions vv and ww:

∥Tv−Tw∥∞≤γ ∥v−w∥∞.\|\mathcal{T}v - \mathcal{T}w\|_\infty \le \gamma\, \|v - w\|_\infty.

The proof is two lines and worth internalizing. The maximum operation is Lipschitz, meaning ∣max⁡af(a)−max⁡ag(a)∣≤max⁡a∣f(a)−g(a)∣|\max_a f(a) - \max_a g(a)| \le \max_a |f(a) - g(a)|. Applying that inside each state, the only difference between the two backups is the term γv(s′)\gamma v(s') versus γw(s′)\gamma w(s'), which differs by at most γ∥v−w∥∞\gamma \|v - w\|_\infty at every successor. Because γ<1\gamma < 1, the operator squeezes any two value functions together by a factor of γ\gamma per application.

Contractions have unique fixed points, and repeated application reaches the fixed point geometrically fast. This gives us value iteration, the workhorse algorithm of small-scale planning:

  1. Initialize v0v_0 arbitrarily, for example to zeros.
  2. Sweep over all states, setting vk+1(s)=(Tvk)(s)v_{k+1}(s) = (\mathcal{T}v_k)(s).
  3. Stop when ∥vk+1−vk∥∞\|v_{k+1} - v_k\|_\infty falls below a tolerance; the result approximates v∗v^*.
  4. Recover the greedy policy π(s)=arg⁡max⁡a∑s′P(s′∣s,a)[R+γv∗(s′)]\pi(s) = \arg\max_a \sum_{s'} P(s' \mid s, a)[R + \gamma v^*(s')].

Each sweep propagates value information one step backward through the transition graph, so the number of sweeps needed depends on both the effective horizon and the structure of the transition graph. Early sweeps carry almost no information; values then ripple outward from rewarded regions until distant states have absorbed news of the goal. We will watch this happen numerically in the gridworld experiment, where the successive-change curve can be checked against the geometric envelope supplied by contraction theory.

Value Functions Connect Prediction to Control

A world model predicts futures; a value function scores them. The pair (P,R)(P, R) defines what will happen and how much it matters, and v∗v^* distills both into a ranking of situations. This is why the qualification test from The World-Model Qualification Test insists on separating open-loop prediction quality from closed-loop decision usefulness: a model can predict well and still induce poor values if its errors concentrate exactly where decisions matter.

It is worth unpacking that last warning with a concrete image. Suppose a learned model forecasts positions perfectly except within a centimeter of the stairwell. Average prediction error might look impressively small, yet an agent that plans through that blind spot will confidently select trajectories ending in the stairwell. The failures are rare, but they sit exactly where decisions carry their largest stakes. Good model quality, measured globally, is therefore neither necessary nor sufficient for good control quality, measured locally; keeping the two assessments apart is one of the recurring disciplines of this book.

Worked Example: Solving a Two-State MDP by Hand

Before writing any code, let us solve a complete MDP analytically. The problem is small enough to do with algebra, which makes the Bellman machinery concrete.

A machine is either working (W) or broken (B). When working, you may operate it, earning reward 4 per step, but each step it breaks with probability 0.1. Alternatively you may service it, earning nothing but keeping it working. When broken, you may repair it at a cost of 2, returning it to working state in one step, or wait and earn nothing while it stays broken. The discount factor is γ=0.9\gamma = 0.9.

First, guess the structure of the optimal policy: operate when working, repair when broken. We will verify the guess afterward. This guess-and-verify pattern is a standard analytical technique: in small problems you can hypothesize the shape of the solution, solve the resulting linear system, and then check that no alternative action contradicts the hypothesis. Under this policy, the Bellman expectation equations read:

v(W)=4+0.9[ 0.9 v(W)+0.1 v(B) ],v(\mathrm{W}) = 4 + 0.9\big[\, 0.9\, v(\mathrm{W}) + 0.1\, v(\mathrm{B}) \,\big], v(B)=−2+0.9 v(W).v(\mathrm{B}) = -2 + 0.9\, v(\mathrm{W}).

Substituting the second equation into the first:

v(W)=4+0.81 v(W)+0.09[ 0.9 v(W)−2 ]=3.82+0.891 v(W).v(\mathrm{W}) = 4 + 0.81\, v(\mathrm{W}) + 0.09\big[\, 0.9\, v(\mathrm{W}) - 2 \,\big] = 3.82 + 0.891\, v(\mathrm{W}).

Solving, v(W)=3.82/0.109≈35.05v(\mathrm{W}) = 3.82 / 0.109 \approx 35.05, and then v(B)≈0.9×35.05−2≈29.54v(\mathrm{B}) \approx 0.9 \times 35.05 - 2 \approx 29.54.

Now verify the guess by checking that neither alternative action beats the assumed one. Servicing instead of operating when working yields 0+0.9×35.05≈31.550 + 0.9 \times 35.05 \approx 31.55, which is less than 35.05. Waiting instead of repairing when broken yields 0.9×29.54≈26.590.9 \times 29.54 \approx 26.59, less than 29.54. Both alternatives lose, so the guessed policy is indeed optimal, and the values are correct.

The guess-and-verify calculation has already certified that operating in W and repairing in B are the winning actions. We can therefore iterate the fixed-policy Bellman backup for those two actions from zero; it reaches the same values that the full max-based optimality operator T\mathcal{T} would compute.

In[5]:
Code
## Two-state maintenance MDP: states W(0), B(1); actions operate/repair taken optimally.
gamma_2s = 0.9
P_opt = np.array(
    [
        [0.9, 0.1],  # working, operating
        [1.0, 0.0],
    ]
)  # broken, repairing
r_vec = np.array([4.0, -2.0])

v_hand = np.array([35.05, 29.54])  # analytic solution from above

v_iter = np.zeros(2)
two_state_errors = []
for sweep in range(300):
    v_next = r_vec + gamma_2s * (P_opt @ v_iter)
    two_state_errors.append(np.max(np.abs(v_next - v_iter)))
    v_iter = v_next
    if two_state_errors[-1] < 1e-10:
        break

ref_line = two_state_errors[0] * gamma_2s ** np.arange(len(two_state_errors))
Out[6]:
Visualization
Log-scale convergence of the fixed-policy Bellman-backup error toward the analytic fixed point.
Repeated fixed-policy Bellman backups for the certified optimal actions converge to the analytic values 35.05 and 29.54, contracting geometrically at rate gamma = 0.9.

The iterates settle onto the exact fixed point computed by substitution, while the displayed hand values are rounded to 35.0535.05 and 29.5429.54. With the stopping rule used here, the remaining numerical fixed-point error is on the order of 10−910^{-9}; the larger dotted offset against the two-decimal hand value is therefore rounding, not failed convergence. The error falls along the γk\gamma^k reference slope.

Three observations are worth drawing out. First, the value of a working machine, about 35, vastly exceeds any single-step reward, because it prices in the entire expected future stream. Value is a stock of future income, not a flow, and the discount factor determines the exchange rate between them. Second, the value gap is exact: v(W)−v(B)=2+0.1v(W)=600/109≈5.5046v(W)-v(B)=2+0.1v(W)=600/109\approx5.5046. The immediate repair cost contributes 2, while the remaining term prices the repair transition against the working state's discounted future. Third, the same numbers would fall out of value iteration automatically: the algebra we did by hand is what the fixed-point iteration computes numerically. Starting from zeros, applying T\mathcal{T} repeatedly converges to these same two numbers without ever forming a linear system explicitly. When a problem is too large to solve as a linear system, iterative methods take its place.

When the Markov Assumption Fails

This section examines how real environments violate the assumptions we just made, why those violations are dangerous, and what conceptual repairs exist. The T-maze experiment later in the chapter measures one such failure precisely.

The Markov property is a statement about a representation, not about the world. The physical world is arguably Markovian at the level of microscopic physics, but the representations available to an agent almost never are. Cameras see surfaces, not velocities; software agents inherit databases, not causal mechanisms. Between the full physical state and whatever the agent records lies an abstraction, and abstractions lose information. The common representation-induced failures fall into a handful of recurring patterns:

  • Sensor aliasing: two distinct situations produce identical observations. Our delivery robot at either end of a symmetric corridor sees the same walls. Anything built only from momentary sensations is blind to the difference, however consequential it may be.
  • Latent physical quantities: variables that matter but are not directly sensed, such as the charge left in a battery, the contents of a closed drawer, or whether a door is locked. These variables influence outcomes while hiding from measurement.
  • Observation delays: the reading available at time tt describes an earlier state, so the current observation alone omits the intervening evolution. Timestamping and stacking delayed observations can restore sufficiency when the delay is known.
  • Exogenous processes: parts of the environment the agent does not model, such as other people moving through the office, inject state changes the agent's sts_t cannot explain. To the agent these events look like irreducible noise, though from a richer viewpoint they are perfectly predictable.
  • Deliberate abstraction: compressed or learned state representations merge situations for the sake of tractability, silently destroying distinctions that matter for control. Dimensionality reduction is safe only when the discarded directions carry no decision-relevant information, which is rarely verifiable for free.

The consequence of these representation failures is the same: the agent's apparent state becomes an unreliable basis for prediction and control. Predictions conditioned on sts_t are systematically biased, because the omitted history carried real information. Note the word systematically: these errors do not average out like sampling noise, because they repeat in exactly the same direction whenever the same hidden context recurs. Worse for decision making, the optimal action can depend on the missing information. In an aliased corridor whose two ends hide a goal and a hazard, no fixed reaction to the current observation can be safe; the right move depends on which end you are actually at, and only your history distinguishes the two.

Two principal formal repairs restore a Markov state, and mature systems often combine them. The first is to enrich the state: engineer or learn features that restore sufficiency, which is the business of Sufficient State and State Abstraction in Part III. The second is to infer the missing information from history: maintain an explicit probability distribution over what the true state might be, and treat that distribution as the effective state. Enrichment pushes the ambiguity backward into sensing; inference pulls it forward into estimation. History-dependent recurrent policies and robust policies can sometimes act effectively without an explicit calibrated belief, but they do not by themselves prove that the chosen state is Markov. The second formal repair is the subject of the next section and, in full generality, of the next chapter on Bayesian filtering.

A separate assumption can fail even when the representation is sufficient: nonstationarity. As tires wear or other agents adapt, yesterday's transition kernel no longer applies. Adding time, wear state, or regime variables can convert predictable drift into a larger stationary model; changes that cannot be represented this way call for online or adaptive identification rather than belief filtering over a fixed hidden state.

Partially Observable Decision Processes

This section formalizes decision making under incomplete observation. The central result is elegant: if the agent summarizes its history into a belief distribution over states, it recovers an MDP, albeit one with a continuous and high-dimensional state space.

Definition: Partially Observable MDP

A POMDP extends an MDP with two ingredients:

  • Ω\Omega: a set of observations,
  • O(o′∣s′,a)O(o' \mid s', a): the emission model, the probability of observing o′o' after taking action aa and landing in state s′s'.

The agent never sees sts_t. It sees only the observation sequence, and its decisions may depend on the entire history ht=(o0,a0,o1,…,ot)h_t = (o_0, a_0, o_1, \ldots, o_t).

Two structural notes help in reading the definition. First, the emission model conditions on the action aa as well as the new state s′s', which captures the fact that sensors are often directional or action-dependent: looking left reveals the left corridor regardless of where the wall actually is. Second, the underlying MDP mechanics are still present and still Markov; partial observability changes what the agent knows, not how the environment evolves. The distinction between epistemic limitation and physical randomness, blurred in everyday speech, is drawn sharply here: slips live in PP, ignorance lives in OO.

The POMDP is the honest formalism for embodied agents. Cameras do not report object velocities, tactile sensors do not report friction coefficients, and a single image does not reveal what is behind the sofa. Any world model deployed on real sensor data is implicitly a POMDP model, whether or not its builders use the term.

Histories and Belief States

With full observability, the optimal policy was a function of the current state. With partial observability, the optimal policy is a function of the entire history, because different histories consistent with the same latest observation can warrant different actions. Two agents standing in front of the same door should turn the handle only if their arrival routes imply the room behind it is unlocked; the latest observation alone cannot say. Histories grow without bound, so we need a compressed summary that preserves everything decision-relevant.

The right summary is the belief state: the posterior distribution over the true state given the history,

bt(s)=P(st=s∣ht).b_t(s) = P(s_t = s \mid h_t).

After taking action ata_t and receiving observation ot+1o_{t+1}, Bayes rule updates the belief:

bt+1(s′)=η  O(ot+1∣s′,at)∑sP(s′∣s,at) bt(s),b_{t+1}(s') = \eta\; O(o_{t+1} \mid s', a_t) \sum_{s} P(s' \mid s, a_t)\, b_t(s),

where η\eta normalizes the distribution. Read the update as a dialogue between prediction and correction: the inner sum predicts where the state might have moved under the action, smearing each unit of belief across successors according to the transition kernel, and the emission factor corrects that prediction in light of what was actually observed, amplifying candidates consistent with the sensor reading and suppressing those inconsistent with it.

A tiny numeric example makes the predictor-corrector dialogue visible. Suppose the robot can be in three corridor cells, L, C, or R, and hears a beep that only the right-hand cell emits reliably.

In[7]:
Code
cells = ["L", "C", "R"]
b0 = np.array([1 / 3, 1 / 3, 1 / 3])  # initial belief: uniform

## Transition: a symmetric inward drift under the chosen action.
P_walk = np.array([[0.6, 0.4, 0.0], [0.2, 0.6, 0.2], [0.0, 0.4, 0.6]])

## Emission P(beep | cell): mostly R, faintly C.
p_beep = np.array([0.05, 0.20, 0.90])

b_pred = P_walk.T @ b0  # prediction: smear forward
eta = p_beep @ b_pred  # normalizer

b_post = p_beep * b_pred / eta  # correction: reweight by evidence
Out[8]:
Visualization
Grouped bar chart: the uniform prior predicts to 0.27, 0.47, 0.27 over L, C, R, then a beep updates the belief to about 0.04, 0.27, 0.69.
Belief over three corridor cells before the action, after predicting through the transition kernel, and after correcting with the observed beep. Prediction moves mass symmetrically toward cell C; correction then raises cell R to about 0.69 while leaving about 0.27 on C.

Prediction alone moves mass symmetrically inward, taking the uniform prior to approximately (0.27,0.47,0.27)(0.27, 0.47, 0.27) over L, C, and R. The beep then suppresses L and shifts the posterior to approximately (0.04,0.27,0.69)(0.04, 0.27, 0.69). Cell R becomes the most likely location, but substantial uncertainty remains on C. One step of the filter has turned an uninformative prior into a useful, calibrated localization by multiplying predictive plausibility against sensor likelihood and renormalizing.

Beliefs that were sharp before an action may widen afterward, reflecting new uncertainty introduced by the transition, then sharpen again when the observation arrives. This is exactly the predictor-corrector structure of the Kalman filter and its nonlinear cousins, which the next chapter develops in depth; the formula above is the discrete-state special case of that whole family.

The Belief MDP

Here is the result that makes POMDPs tractable to reason about. Treat the belief btb_t itself as a state. The belief evolves stochastically (through the observations it receives), it is Markov (because it is a deterministic function of the previous belief, action, and fresh observation noise), and it carries a well-defined expected reward:

ρ(b,a)=∑sb(s)∑s′P(s′∣s,a) R(s,a,s′).\rho(b, a) = \sum_{s} b(s) \sum_{s'} P(s' \mid s, a)\, R(s, a, s').

The intuition for the Markov claim is subtle but crucial. The old state sts_t was Markov for the environment, but the agent's observation stream is not Markov in oto_t: knowing only the latest pixel, you cannot know where you are. Under the POMDP transition and observation model defined above, the true posterior belief condenses all evidential content of the history. Since bt+1b_{t+1} is computed from (bt,at,ot+1)(b_t, a_t, o_{t+1}) alone, conditioning on the pair (belief, action) leaves nothing predictive in earlier beliefs, which restores the property that made planning recursive in the first place. This theorem concerns the true posterior under the true model. If an agent updates a surrogate belief with misspecified transition or observation probabilities, that internal state need not retain all predictive information in the history.

The POMDP is therefore equivalent to an MDP over the space of beliefs. Early incomplete-information control work includes Åström's 1965 formulation, while Smallwood and Sondik's 1973 finite-horizon analysis developed belief-space dynamic programming and its piecewise-linear convex value structure. All the machinery of the first half of this chapter applies, with one sobering caveat: the belief space is a continuum of probability distributions, with dimension equal to the number of states minus one. Exact value iteration over beliefs is practical only for tiny problems, and finding optimal POMDP policies is computationally intractable in the worst case. Practical systems use approximations such as point-based value iteration, particle filters, or, increasingly, learned latent representations that play the role of beliefs implicitly. Those approximations occupy several later chapters.

One further wrinkle distinguishes belief-space planning from ordinary MDP planning: because collecting information changes the belief, acting can serve two purposes at once. An action might gather reward or gather evidence, and sometimes the best evidence-gathering move earns nothing immediately. This state-information tension vanishes in a fully observed problem with known dynamics, where no action teaches the agent anything new about the current state or model. Fully observed problems with unknown dynamics can still require exploration to learn the model.

Beliefs, Memory, and World Models

The belief state explains why memory helps. An agent without memory can only react to its latest observation; an agent that maintains a belief carries forward everything its history taught it. Recurrent world models, which we will meet in Part III, learn exactly this skill end to end: their latent state is trained to be a sufficient summary of history for predicting and controlling the future, performing implicitly the job that the Bayes update performs explicitly here.

Implementation: Planning a Gridworld with Value Iteration

We now make the first half of the chapter executable. Our running example is a 5×55\times5 office gridworld: the delivery robot starts at the bottom-left corner, a charging goal sits at the top-right, and an open stairwell (a pit) sits at the center. Each move succeeds with probability 0.8 and slips to a perpendicular direction with probability 0.1 each, simulating the slippery floor. Reaching the goal earns 20, falling into the pit costs 20, and every other step costs 1, encouraging short routes.

First, the imports and the environment model. We represent the transition kernel and reward function as dense arrays, indexed as T[action, state, next_state].

In[9]:
Code
import matplotlib.pyplot as plt
import numpy as np

n = 5  # 5x5 grid
S = n * n
idx = lambda r, c: r * n + c
goal, pit, start = idx(0, 4), idx(2, 2), idx(4, 0)

moves = [(-1, 0), (1, 0), (0, -1), (0, 1)]  # up, down, left, right
perp = {0: [2, 3], 1: [2, 3], 2: [0, 1], 3: [0, 1]}
slip = 0.1  # probability of each perpendicular slip

T = np.zeros((4, S, S))  # T[a, s, s']
Rmat = np.full((4, S, S), -1.0)  # Rmat[a, s, s'], step cost by default

for a, (dr, dc) in enumerate(moves):
    for r in range(n):
        for c in range(n):
            s = idx(r, c)
            if s in (goal, pit):  # terminals absorb with no further reward
                T[a, s, s] = 1.0
                Rmat[a, s, s] = 0.0
                continue
            for b, (br, bc) in enumerate(moves):
                if b == a:
                    p = 1.0 - 2 * slip
                elif b in perp[a]:
                    p = slip
                else:
                    continue
                nr = min(max(r + br, 0), n - 1)  # bumping a wall: stay put
                nc = min(max(c + bc, 0), n - 1)
                ns = idx(nr, nc)
                T[a, s, ns] += p
                Rmat[a, s, ns] = (
                    20.0 if ns == goal else (-20.0 if ns == pit else -1.0)
                )

assert np.allclose(T.sum(axis=2), 1.0)
for terminal in (goal, pit):
    assert np.allclose(T[:, terminal, terminal], 1.0)
    assert np.allclose(Rmat[:, terminal, terminal], 0.0)

The arrays encode everything the planner needs: dynamics, slip stochasticity, wall clamping, and rewards. Note that the reward is attached to transitions, so stepping into the goal collects 20 exactly once, and the absorbing self-loops at terminals carry zero reward to keep values finite. The += accumulation matters in the corners: an attempted move off the grid clamps back to the same cell, so several probability masses can land on a single successor and must be summed rather than overwritten. At the top-left corner under a leftward action, for example, the intended move contributes 0.80.8 to the clamped self-transition and the upward perpendicular slip contributes another 0.10.1, for total self-transition mass 0.90.9.

Next, value iteration. We record the maximum change per sweep so we can inspect the contraction behavior predicted by the theory.

In[10]:
Code
gamma = 0.9
V = np.zeros(S)
errors = []

for k in range(500):
    Q = (T * Rmat).sum(axis=2) + gamma * (T @ V)  # Q[a, s]
    V_new = Q.max(axis=0)
    errors.append(np.max(np.abs(V_new - V)))
    V = V_new
    if errors[-1] < 1e-12:
        break

Q = (T * Rmat).sum(axis=2) + gamma * (T @ V)
greedy_policy = Q.argmax(axis=0)
Out[11]:
Console
Converged in 53 sweeps, final change 5.87e-13
V*(start) = 1.440
V*(goal)  = 0.000,  V*(pit) = 0.000

The contraction analysis supplies a conservative sweep bound: with γ=0.9\gamma = 0.9, successive Bellman-backup differences can shrink by at most a factor of 0.9. The first recorded change is 15.815.8, attained by a goal-adjacent state whose best action enters the goal, so the envelope 15.8(0.9)k<10−1215.8(0.9)^k < 10^{-12} first crosses the threshold at the zero-based envelope index k=289k=289, corresponding to the 290th recorded sweep, or roughly three hundred sweeps. Executing the cell above reaches the stopping tolerance in 53 sweeps. The gap is expected: 0.90.9 is a worst-case contraction factor, while this grid's transition structure yields faster realized shrinkage. There is a compact way to see the backup arithmetic in the code itself: the line computing Q first averages immediate expected rewards over successors, then adds the discounted value of successors, so a single matrix product performs one full Bellman backup for every state and action simultaneously. Let us compare the observed decline with the theoretical envelope.

Out[12]:
Visualization
Log-scale plot of value iteration error shrinking geometrically with sweeps.
Maximum successive change in the value function per value iteration sweep, on a log scale. The observed geometric decline is at or below the conservative envelope defined by the contraction factor gamma = 0.9, with equality at the initial sweep.

The observed curve equals the γk\gamma^k reference envelope at the initial sweep and stays strictly below it afterward, reaching the tolerance much sooner than the worst-case bound requires. Its near-straight descent on the logarithmic axis indicates geometric shrinkage, while its steeper slope shows that the realized rate is faster than γ\gamma. The Bellman operator's sup-norm Lipschitz constant is γ\gamma, so each successive difference contracts by at most that factor; an individual sweep need not attain the bound. This distinction matters: contraction theory guarantees convergence for the exact discounted Bellman operator, but it does not say every problem attains the worst-case rate. If a practical planner fails to converge, inspect whether its update is actually the same contraction mapping—for example, approximation, changing models, or optimization error can invalidate that premise.

Now the interesting output: the optimal value surface and the policy it induces.

Out[13]:
Visualization
Gridworld heatmap of optimal values with greedy policy arrows routed around the pit.
Optimal state values (color) and greedy policy (arrows) in the 5x5 gridworld. Arrows route around the central pit, and values decay with distance from the goal.

Read the figure as a decision-making document. Color encodes v∗v^*: bright near the goal, dark near the pit, with a visible valley of low value surrounding the hazard. The arrows use only up and right in this seeded grid, but their routing bends around the pit rather than taking the most direct diagonal corridor, because the greedy policy weighs the 0.2 total slip probability against a 20-unit penalty. This is exactly the kind of behavior that emerges from the Bellman backup without ever being programmed in: risk-aware routing is a consequence of expected-value arithmetic, not a hand-coded rule.

Finally, let us close the loop between theory and simulation. If v∗v^* really is the expected return of the greedy policy, then Monte Carlo rollouts of that policy should reproduce v∗(start)v^*(\text{start}) up to sampling noise. This is the chapter's first taste of validation practice: never trust a planned value until simulated experience confirms it.

In[14]:
Code
def rollout(policy_fn, rng, max_steps=100):
    s, G, disc = start, 0.0, 1.0
    for _ in range(max_steps):
        a = policy_fn(s)
        s_next = rng.choice(S, p=T[a, s])
        G += disc * Rmat[a, s, s_next]
        disc *= gamma
        s = s_next
        if s in (goal, pit):
            break
    return G


rng = np.random.default_rng(0)
mc_returns = np.array(
    [rollout(lambda s: int(greedy_policy[s]), rng) for _ in range(3000)]
)
Out[15]:
Console
Monte Carlo mean return : 1.425 +/- 0.064 (standard error)
Planned value V*(start) : 1.440

The two numbers agree closely, which is the entire point of the exercise. The value function computed by iterating the Bellman operator is not an abstract score; it is a verifiable prediction about closed-loop performance. Discrepancies here would indicate a bug, a modeling mismatch between rollout and planner, or statistical noise, and telling those apart is a skill in its own right. When a learned world model's planned values diverge from realized returns in later chapters, this gridworld check is the minimal diagnostic you should reach for.

Beyond matching means, the shape of the return distribution itself carries diagnostic information. The next plot separates the rollouts into those that reached the goal and those that fell into the pit.

In[16]:
Code
def rollout_with_outcome(policy_fn, rng, max_steps=100):
    s, G, disc = start, 0.0, 1.0
    for _ in range(max_steps):
        a = policy_fn(s)
        s_next = rng.choice(S, p=T[a, s])
        G += disc * Rmat[a, s, s_next]
        disc *= gamma
        s = s_next
        if s in (goal, pit):
            break
    return G, s


rng_dist = np.random.default_rng(42)  # fresh seed so this run is reproducible
returns_g, returns_p, returns_timeout = [], [], []
for _ in range(4000):
    G, final = rollout_with_outcome(lambda s: int(greedy_policy[s]), rng_dist)
    if final == goal:
        returns_g.append(G)
    elif final == pit:
        returns_p.append(G)
    else:
        returns_timeout.append(G)
planned_start_value = V[start]
assert len(returns_g) > 0 and len(returns_p) > 0
assert len(returns_timeout) == 0
assert len(returns_g) + len(returns_p) == 4000
assert np.isclose(planned_start_value, 1.440, atol=5e-4)
Out[17]:
Visualization
Histogram of rollout returns by outcome with the planned value overlaid.
Seeded Monte Carlo returns for the greedy policy, split by terminal outcome, with V*(start) marked. In this run successful-delivery returns occur on both sides of the planned value, goal outcomes are more frequent, and the pit-fall lobe lies far below zero. The planned value predicts the population mean across outcomes, not the center of either empirical lobe.

Two distinct lobes appear instead of a symmetric spread around the mean: a tall lobe of successful deliveries whose returns spread across the planned value, with unobstructed routes landing above it and early slip-induced detours landing below, and a thin but costly lobe of pit outcomes far below zero. All 4,000 seeded rollouts reached one of the two terminals within the 100-step cap; the code asserts that no timeout was silently discarded. The empirical mean differs slightly from the planned value because of finite-sample noise. The value-iteration approximation contributes at most about 10−1110^{-11} here, negligible beside the Monte Carlo standard error. Within the two-lobe empirical decomposition, increasing the pre-change pit probability from pp to 2p2p while holding the conditional return distributions fixed would shift the population mean by pp times the gap between their conditional means. That is why the tail should be inspected separately from the average.

Key Parameters

The key parameters for the gridworld planning experiment are:

  • gamma: Discount factor, set to 0.9. It controls how far ahead the agent plans and sets the geometric contraction rate of value iteration.
  • slip: Slip probability, set to 0.1 per perpendicular direction. Together with the 0.8 success probability it models the slippery floor.
  • Reward schedule: Entering the goal earns 20, entering the pit costs 20, and every other step costs 1, encouraging short, safe routes.
  • Tolerance: Sweeping stops when the maximum per-sweep value change falls below 1e-12, placing the returned values within roughly 1e-11 of the exact fixed point and making them effectively exact for this example.

Implementation: Memory in a T-Maze

We now measure what partial observability costs and what belief tracking buys. The testbed is the classic T-maze, stripped to its essentials. This example uses the undiscounted sum over its finite two-action episode, equivalently γ=1\gamma=1 for that bounded horizon.

At the start of each episode, the agent stands at the base of a T-shaped maze and glimpses a noisy cue telling it which arm holds the reward: the cue is correct with probability 0.9. The agent then advances to the junction. Crucially, at the junction the observation carries no information about the cue; the glimpse is gone. Entering the correct arm pays 4, entering the wrong arm pays -4, and every action costs 0.1. The latent variable "which arm is good" is drawn fresh each episode, so nothing can be memorized across episodes; the only path to above-chance performance runs through within-episode memory.

This tiny world isolates the phenomenon from the previous section: the optimal action at the junction depends on information that exists only in the agent's history. Let us code four agents that differ in how much episode information they can use: one reads the latent state directly, one remembers the cue as a belief, and two choose without retaining the cue.

In[18]:
Code
CUE_ACCURACY = 0.9
STEP_COST = 0.1
ARM_REWARD = 4.0

OBS_CUE_LEFT, OBS_CUE_RIGHT, OBS_JUNCTION, OBS_LEFT_END, OBS_RIGHT_END = range(
    5
)


def tmaze_step(obs, action, good, rng):
    """Enforce the two-stage protocol: advance from a cue, then choose an arm."""
    if obs in (OBS_CUE_LEFT, OBS_CUE_RIGHT):
        if action != 0:
            raise ValueError(
                "An arm cannot be chosen before reaching the junction"
            )
        return OBS_JUNCTION, -STEP_COST, False
    if obs != OBS_JUNCTION:
        raise ValueError("The episode has already terminated")
    if action not in (1, 2):
        return OBS_JUNCTION, -STEP_COST, False
    reward = ARM_REWARD if (action - 1) == good else -ARM_REWARD
    return OBS_LEFT_END + (action - 1), reward - STEP_COST, True


class OracleAgent:
    """Knows the latent variable directly; upper bound on performance."""

    def __init__(self, good):
        self.good = good

    def act(self, obs):
        return 0 if obs in (OBS_CUE_LEFT, OBS_CUE_RIGHT) else 1 + self.good


class MemoryAgent:
    """Maintains the belief P(good = right) implied by the cue, then acts on it."""

    def __init__(self, good=None):
        self.belief_right = 0.5

    def act(self, obs):
        if obs in (OBS_CUE_LEFT, OBS_CUE_RIGHT):
            self.belief_right = (
                CUE_ACCURACY if obs == OBS_CUE_RIGHT else 1.0 - CUE_ACCURACY
            )
            return 0
        return 2 if self.belief_right >= 0.5 else 1


class ReactiveAgent:
    """Maps the current observation to an action; no memory of the cue."""

    def __init__(self, good=None, junction_action=1):
        self.junction_action = junction_action

    def act(self, obs):
        return (
            0 if obs in (OBS_CUE_LEFT, OBS_CUE_RIGHT) else self.junction_action
        )


class RandomAgent:
    """Chooses an arm uniformly at the junction."""

    def __init__(self, rng, good=None):
        self.rng = rng

    def act(self, obs):
        if obs in (OBS_CUE_LEFT, OBS_CUE_RIGHT):
            return 0
        return 1 + int(self.rng.random() < 0.5)

Look closely at the MemoryAgent. Its single internal variable is the posterior P(good=right∣cue)P(\text{good} = \text{right} \mid \text{cue}), computed by Bayes rule with a uniform prior. With cue accuracy 0.9, seeing the right cue sets the belief to 0.9 and seeing the left cue sets it to 0.1. The agent always chooses the arm indicated by the cue, so its choice agrees with the cue with probability 1 and with the truly rewarded arm with probability 0.9. That one number, carried across the delay, is the entire difference between this agent and the reactive one. Notice also that the oracle and the reactive agent occupy opposite poles of an information-access spectrum: the oracle reads the latent variable straight from the simulator, an upper bound no real sensor-based agent can reach, while the reactive agent discards the cue before choosing an arm.

Before simulating, we can compute the expected returns analytically. The oracle always earns 4−0.2=3.84 - 0.2 = 3.8. The memory agent picks the correct arm with probability 0.9, giving 0.9×3.8+0.1×(−4.2)=3.00.9 \times 3.8 + 0.1 \times (-4.2) = 3.0. Among memoryless policies that commit to an arm at the junction, every arm-choice distribution wins half the time and therefore has expected return 0.5×3.8+0.5×(−4.2)=−0.20.5 \times 3.8 + 0.5 \times (-4.2) = -0.2. A policy that stalls instead of committing can do worse because it keeps paying the step cost. Simulation should reproduce the committing-policy values.

In[19]:
Code
def evaluate(make_agent, n_episodes=4000, seed=7):
    rng = np.random.default_rng(seed)
    action_rng = np.random.default_rng(seed + 1)
    totals = []
    for _ in range(n_episodes):
        good = int(rng.random() < 0.5)
        cue = good if rng.random() < CUE_ACCURACY else 1 - good
        agent = make_agent(good, action_rng)
        G, obs, done = 0.0, OBS_CUE_LEFT + cue, False
        for _ in range(10):
            G += 0.0
            obs, r, done = tmaze_step(obs, agent.act(obs), good, rng)
            G += r
            if done:
                break
        totals.append(G)
    return np.array(totals)


results = {
    "Oracle": evaluate(lambda g, rng: OracleAgent(g)),
    "Memory": evaluate(lambda g, rng: MemoryAgent()),
    "Reactive": evaluate(lambda g, rng: ReactiveAgent(junction_action=1)),
    "Random": evaluate(lambda g, rng: RandomAgent(rng)),
}

correct_arm_return = ARM_REWARD - 2 * STEP_COST
wrong_arm_return = -ARM_REWARD - 2 * STEP_COST
guess_probability = 0.5
theory = {
    "Oracle": correct_arm_return,
    "Memory": CUE_ACCURACY * correct_arm_return
    + (1 - CUE_ACCURACY) * wrong_arm_return,
    "Reactive": guess_probability * correct_arm_return
    + (1 - guess_probability) * wrong_arm_return,
    "Random": guess_probability * correct_arm_return
    + (1 - guess_probability) * wrong_arm_return,
}
Out[20]:
Console
Oracle    empirical +3.800   theory +3.800
Memory    empirical +2.982   theory +3.000
Reactive  empirical -0.214   theory -0.200
Random    empirical -0.246   theory -0.200

The empirical means match the analytical predictions within sampling error, and the gap between the memory agent and the reactive agent, more than three reward units per episode, is the measured price of forgetting. We predicted each agent's mean return in closed form before running the simulation. Agreement between analytic prediction and empirical sample checks both the environment code and our model of it, following the same discipline as the Monte Carlo check in the gridworld. Let us visualize the comparison.

Out[21]:
Visualization
Bar chart of average T-maze returns: memory agent near oracle, reactive agent negative.
Average return per episode in the T-maze across 4000 episodes (error bars show one standard deviation). Maintaining a belief from the cue recovers most of the oracle's performance, while reactive policies lose money on average.

The pattern in the bars tells the whole story of this chapter in one glance. The oracle bar is the ceiling imposed by the environment's latent variable. The memory bar nearly touches it, and the residual gap is 3.8−3.0=0.83.8-3.0=0.8 reward units: exactly the cost of the cue being wrong on 10% of episodes, since each wrong arm changes the outcome by 3.8−(−4.2)=8.03.8-(-4.2)=8.0. This is a perceptual limitation rather than a cognitive one. No amount of additional reasoning can extract information the sensor never delivered; this decomposition of performance loss into perceptual versus cognitive components is worth carrying into every applied project. The reactive and random bars sit below zero: an agent that cannot retain information is not merely suboptimal, it is actively losing, because half of its committed guesses walk into the punished arm. Suboptimality sounds benign; negative expected return does not, and the difference between the two words is the difference between a minor engineering flaw and a system you should switch off.

The error bars describe dispersion across episodes, not uncertainty in the plotted means. The oracle follows the same successful path every time, so its standard-deviation bar has zero width. The memory agent's return varies only with whether the cue is correct. The reactive agent always commits to the right arm, so its return varies with which arm the environment rewarded. For the random agent, a separate random-number stream makes its arm choice statistically independent of that rewarded-arm draw; the return still depends on both variables because it is determined by whether they match. Their intervals overlap, but that overlap should not be read as evidence that the policies have equal expected performance.

It is worth pausing on what the memory agent's belief is for. In this maze the belief never changes after the cue, because no later observation or action reveals anything about the latent variable; the Bayes update fires exactly once per episode and thereafter just holds steady. Real environments are kinder: actions usually generate informative observations, so beliefs evolve continuously as the agent explores. Tracking a belief over both position and latent variables, using the full predictor-corrector update, is precisely the business of the next chapter, Bayesian Filtering and Belief States. The T-maze is the degenerate but clarifying case where the filter reduces to remembering one number.

Key Parameters for the T-Maze

The key parameters for the T-maze experiment are:

  • CUE_ACCURACY: Probability, set to 0.9, that the starting cue identifies the rewarded arm correctly.
  • STEP_COST: Cost per action, set to 0.1, incurred both at the junction advance and upon entering an arm.
  • ARM_REWARD: Reward magnitude, set to 4.0, paid for entering the correct arm and penalized for entering the wrong arm.
  • seed: Random generator seed 7 controls environment sampling; seed 8 controls the random agent's independent action stream. Both keep the experiment reproducible without repeating the same first draw in every episode.
  • n_episodes: Number of evaluation episodes, set to 4000, which tightens the empirical estimates against the analytical predictions.

Limitations and Impact

The MDP and POMDP formalisms give control, operations research, and reinforcement learning a shared vocabulary for dynamics, observations, objectives, and decisions. When we speak of a world model as something an agent plans against, the mathematical content of that sentence is an approximation of PP, RR, and, under partial observability, OO, evaluated through the value-function lens this chapter built. Learned latent-state systems preserve the same division of labor when an encoder supplies an internal state, a transition model predicts how it evolves, and a policy or planner chooses actions against those predictions.

The limitations are equally structural, and it is better to meet them now than to discover them mid-project. First, the curse of dimensionality is not an implementation detail but a property of the representation. A belief over ∣S∣|\mathcal{S}| enumerated states lies on a simplex of dimension ∣S∣−1|\mathcal{S}|-1; if the underlying state combines mm variables with dd possibilities each, then ∣S∣=dm|\mathcal{S}|=d^m and the belief representation grows exponentially in mm. This arithmetic alone explains why exact tabular methods quickly become impractical and why later chapters rely on sampled trajectories, learned value functions, point-based belief planning, or amortized policies. Second, the framework takes the reward function as given, yet specifying rewards that capture what we actually want is notoriously difficult, and optimizing a misspecified reward faithfully can be worse than useless. This is the scalar-reward flattening danger promised in the opening: a single number can collapse incompatible goals, hide distributional consequences, and reward proxies that cease to track the intended outcome. An agent that maximizes the letter of a flawed specification does so relentlessly; the scalar objective treated here as an axiom is also a major source of silent failure. The safety questions of Part XII begin right here, at the moment we declare a scalar sufficient. Third, the assumptions are fragile in practice. Stationarity fails as mechanisms wear and other agents adapt, while the Markov property fails whenever the chosen representation loses information. These are distinct failure modes, though predictable drift can sometimes be absorbed into an enlarged state. As the T-maze showed, representation loss can flip a profitable agent into a losing one. The engineering responses (enriching the state, inferring beliefs, learning representations that preserve decision-relevant information, and adapting the dynamics model under drift) are not optional refinements. They are where most of the real difficulty lives.

A final limitation deserves emphasis because it recurs throughout the book: everything in this chapter evaluates a policy against a model of the environment, and the model can be wrong. Value iteration on an inaccurate PP produces confidently wrong values, and an agent that plans against its own model can exploit model errors in ways that look brilliant in simulation and fail in reality. Notice the asymmetry between the two kinds of error: errors in PP distort predictions broadly, but errors concentrated along the trajectory the plan happens to prefer are the dangerous ones, because the optimizer actively seeks out whichever futures the model rates most favorably, accurate or not. This gap between model-space optimality and environment-space performance, sometimes called model exploitation, is a first-class concern we will carry into model-based reinforcement learning and the reliability chapters. The Monte Carlo validation loop from the gridworld experiment, comparing planned values against realized returns, is the humble prototype of the safeguards those chapters develop.

Summary

This chapter built the formal backbone for everything that follows:

  • An MDP (S,A,P,R,γ,ρ0)(\mathcal{S}, \mathcal{A}, P, R, \gamma, \rho_0) couples a world model (the transition kernel) with an objective (the reward function) and a time preference (the discount factor).
  • The Markov property licenses compressing entire histories into the current state. It is a property of a representation, not of the world, and it can fail through sensor aliasing, omitted latent variables, observation delays, exogenous processes, or lossy abstraction. Nonstationarity is a separate dynamics assumption: under drift, the same represented state and action need not retain the same transition law over time.
  • Returns accumulate discounted reward; the effective horizon 1/(1−γ)1/(1-\gamma) expresses how far ahead the agent reasons.
  • Value functions convert long-horizon expectations into per-state scores. The Bellman equations make them recursive, and the Bellman operator's γ\gamma-contraction guarantees that value iteration converges to the unique optimal value function, from which a greedy policy is recovered.
  • POMDPs model partial observability with an emission model. The optimal policy depends on history, but the belief state, the posterior over true states given history, restores the Markov property at the cost of a continuous, high-dimensional state space.
  • The T-maze experiment quantified the stakes: maintaining a belief recovered most of an oracle's performance, while reactive policies lost reward on average. Memory is not a convenience; under partial observability it is the difference between profit and loss.

You now have the decision-theoretic skeleton on which every later chapter hangs. You can define a decision problem precisely, evaluate any policy against it recursively, plan optimally when the model is known and the state visible, and state exactly which assumptions collapse when observation becomes incomplete. The immediate next step is the one this chapter motivated but deferred: how to compute and maintain beliefs efficiently, with the Kalman filter as the canonical case. That is the subject of the next chapter, Bayesian Filtering and Belief States.

Quiz

Ready to test your understanding? Take this quick quiz to reinforce what you've learned about Markov and partially observable decision processes.

Markov and Partially Observable Decision Processes Quiz

Question 1 of 70 of 7 completed
What makes a state representation Markov?

Comments

No comments yet. Be the first to share your thoughts!

Reference

Citation details

Cite or share this article.

BIBTEXAcademic
@misc{brenndoerfer2026markovpartially, author = {Michael Brenndoerfer}, title = {Markov and Partially Observable Decision Processes}, year = {2026}, url = {https://mbrenndoerfer.com/writing/markov-and-partially-observable-decision-processes}, organization = {mbrenndoerfer.com}, note = {Accessed: 2026-10-13} }
APAAcademic
Michael Brenndoerfer (2026). Markov and Partially Observable Decision Processes. Retrieved from https://mbrenndoerfer.com/writing/markov-and-partially-observable-decision-processes
MLAAcademic
Michael Brenndoerfer. "Markov and Partially Observable Decision Processes." 2026. Web. October 13, 2026. <https://mbrenndoerfer.com/writing/markov-and-partially-observable-decision-processes>.
CHICAGOAcademic
Michael Brenndoerfer. "Markov and Partially Observable Decision Processes." Accessed October 13, 2026. https://mbrenndoerfer.com/writing/markov-and-partially-observable-decision-processes.
HARVARDAcademic
Michael Brenndoerfer (2026) 'Markov and Partially Observable Decision Processes'. Available at: https://mbrenndoerfer.com/writing/markov-and-partially-observable-decision-processes (Accessed: October 13, 2026).
SimpleBasic
Michael Brenndoerfer (2026). Markov and Partially Observable Decision Processes. https://mbrenndoerfer.com/writing/markov-and-partially-observable-decision-processes

About the author

Continue with the full handbook

This chapter is part of World Models Handbook. Use the handbook page to browse the complete table of contents and continue reading in sequence.

Explore World Models Handbook
Newsletter

Stay up to date

Get articles, book updates, and news delivered to your inbox.

No spam, unsubscribe anytime.

or

Join the community

Sign in to remove popups, track your reading progress, and join the discussion.