Modelling Observation Errors: POMDPs

Everything in §5.2–5.4 assumed that Bolt knows which state it is in. The policy \(\pi(s)\) needs \(s\) as input. But Bolt's GPS is useless indoors, its camera is fooled by glass doors, and its wheel encoders drift. Real agents get observations that are noisy, partial clues about the state. This section models those observation errors.

From MDP to POMDP

A partially observable MDP adds two things to an MDP \((S, A, P, R, \gamma)\):

  • A set of observations \(O\) (e.g. {sees door, sees wall}).
  • A sensor model \(P(o \mid s)\): the probability of perceiving \(o\) in state \(s\). (Sometimes \(P(o \mid s, a)\), if the observation depends on the action.)

The agent never sees \(s\). It sees only \(o\).

The sensor model is the model of observation error. "The door detector is right 90% of the time" means \(P(\text{door} \mid \text{door cell}) = 0.9\) and \(P(\text{door} \mid \text{wall cell}) = 0.1\). A perfect sensor has \(P(o\mid s) \in \{0,1\}\), and the POMDP becomes an MDP again.

Belief states

If Bolt can't know its state, what should its policy depend on? The answer: on everything it believes about the state, a probability distribution over states called the belief state:

$$ b(s) = P(S_t = s \mid o_1, a_1, o_2, a_2, \dots, o_t). $$

The belief summarizes the entire history of actions and observations, and it is all the agent needs. (It is a sufficient statistic.) The optimal action depends only on \(b\), not on the raw history.

Intuition

You wake up in a dark hotel corridor. You don't know which room you're outside. You feel a door handle on your left: that rules out the stretches with no doors. You walk three steps and feel nothing: that rules out more. Your "map of where I might be" sharpens with each observation and blurs slightly each time you move, because your steps aren't perfectly measured. That map is the belief state, and the rule for updating it is Bayes' rule.

The belief update (filtering)

After doing action \(a\) in belief \(b\) and then observing \(o\), the new belief is:

$$ \boxed{\; b'(s') = \alpha\; P(o \mid s') \sum_{s} P(s' \mid s, a)\, b(s) \;} $$

Read it right to left, as two steps:

  1. Predict (motion): \(\bar b(s') = \sum_s P(s' \mid s, a)\, b(s)\). Push the belief through the transition model. Uncertainty grows, because motion is noisy.
  2. Correct (sensing): \(b'(s') = \alpha\, P(o \mid s')\, \bar b(s')\). Weight each state by how well it explains the observation, then normalize. This is exactly Bayes' rule from §4.2, with \(\bar b\) as the prior and \(P(o|s')\) as the likelihood. Uncertainty shrinks.

This predict–correct loop is the Bayes filter. With Gaussian beliefs it becomes the Kalman filter, used in every GPS, phone and spacecraft. With samples it becomes the particle filter, used in robot localization.

Try this: press Sense once, and the belief splits into a few bumps, one at each door. Then Move right: the bumps shift and spread. Then Sense again. Repeat a few times and one peak wins. Lower the sensor accuracy to 0.6 and see how much longer it takes. Tick "peek" to check whether Bolt is right.

Worked example in code

A corridor of 10 cells with doors at 1, 3 and 7. The door sensor is 90% accurate. Bolt senses, then moves right, then repeats.

import numpy as np

# Bolt in a corridor of 10 cells. Doors at cells 1, 3 and 7. Bolt doesn't know where it is.
N = 10
door = np.zeros(N, dtype=bool); door[[1, 3, 7]] = True

# Transition model for "move right": 0.8 moves one cell, 0.1 stays, 0.1 moves two (wheel slip)
T = np.zeros((N, N))                       # T[s, s'] = P(s' | s, right)
for s in range(N):
    for ds, p in [(1, 0.8), (0, 0.1), (2, 0.1)]:
        T[s, min(N - 1, s + ds)] += p

# Sensor model: says "door" correctly 90% of the time
def obs_likelihood(saw_door):
    return np.where(door == saw_door, 0.9, 0.1)          # P(o | s) for every s

def predict(b):                     # b'(s') = sum_s P(s'|s,a) b(s)
    return b @ T

def update(b, saw_door):            # b'(s) = alpha * P(o|s) * b(s)
    b = obs_likelihood(saw_door) * b
    return b / b.sum()

b = np.full(N, 1 / N)               # uniform: "I could be anywhere"
for t, saw in enumerate([True, False, True, False]):
    b = update(b, saw)
    print(f"t={t} sensed {'DOOR' if saw else 'wall'}: ", np.round(b, 2))
    b = predict(b)
print("most likely cell:", b.argmax(), "with belief %.2f" % b.max())
t=0 sensed DOOR:  [0.03 0.26 0.03 0.26 0.03 0.03 0.03 0.26 0.03 0.03]
t=1 sensed wall:  [0.   0.01 0.26 0.01 0.26 0.06 0.03 0.01 0.26 0.1 ]
t=2 sensed DOOR:  [0.   0.01 0.01 0.63 0.02 0.07 0.03 0.11 0.01 0.11]
t=3 sensed wall:  [0.   0.   0.01 0.01 0.56 0.1  0.07 0.   0.1  0.15]
most likely cell: 5 with belief 0.46

Follow the story. At t=0, "door" means Bolt is at one of the three doors, about 26% each. After moving right and sensing a wall, all three hypotheses survive (each door has a wall to its right). At t=2, "door" again: only the hypothesis "I started at door 1" predicts a door two cells later (cell 3), so its probability jumps to 0.63. The pattern of observations over time pins down the location, even though no single observation could.

Exam corner: one belief update by hand

Two states \(\{A, B\}\), belief \(b = (0.5, 0.5)\). An action keeps the state with probability 0.7 and switches with probability 0.3. The sensor reports the true state with probability 0.8. After the action, you observe "A".

  1. Predict: \(\bar b(A) = 0.7(0.5) + 0.3(0.5) = 0.5\), and \(\bar b(B) = 0.5\).
  2. Correct: unnormalized \((0.8 \times 0.5,\ 0.2\times 0.5) = (0.4, 0.1)\).
  3. Normalize: \(b' = (0.8, 0.2)\).

Observe "A" again after another action. Predict: \(\bar b(A) = 0.7(0.8)+0.3(0.2) = 0.62\) and \(\bar b(B) = 0.38\). Correct: \((0.8 \times 0.62,\ 0.2 \times 0.38) = (0.496, 0.076)\), so \(b' \approx (0.867, 0.133)\).

Decisions in a POMDP: the belief-state MDP

The key theoretical move: treat the belief as the state. Then

  • the "state" \(b\) is fully observable, since the agent always knows its own belief;
  • the transitions are probabilistic: from \(b\) and action \(a\), the next belief depends on which observation arrives, which happens with probability \(P(o \mid b, a) = \sum_{s'} P(o|s') \sum_s P(s'|s,a)b(s)\);
  • the reward is the expected reward, \(\rho(b) = \sum_s b(s) R(s)\).

So a POMDP is an MDP over beliefs, and the optimal policy is \(\pi^*(b)\). The catch is that the belief space is continuous: with \(n\) states, beliefs live in an \((n-1)\)-dimensional simplex. Value iteration over a continuous space is a different game.

Why POMDPs are hard, and how they're solved

  • For a finite horizon, the optimal value function over beliefs is piecewise linear and convex. It is the max of a set of linear functions ("α-vectors"), each corresponding to a conditional plan. Exact POMDP value iteration manipulates these α-vectors, but their number can grow exponentially with the horizon. Solving POMDPs exactly is PSPACE-hard.
  • Approximations are used in practice: point-based value iteration (only update at sampled beliefs), online lookahead search from the current belief, and the QMDP heuristic: solve the underlying MDP to get \(Q(s,a)\), then act by \(\arg\max_a \sum_s b(s) Q(s,a)\).
The flaw of QMDP, and the beauty of POMDPs

QMDP assumes all uncertainty will vanish after one step, so it never takes an action purely to gather information, like "stop and look around." A true POMDP solution values information automatically. Actions that reduce uncertainty raise the expected value of future decisions. This is the value of information (§5.1) appearing again, now inside sequential decisions.

Assignment notes

POMDP assignments usually ask you to (1) specify a POMDP: list states, actions, observations, the transition table, the observation table and rewards, often in the .pomdp file format used by solvers like pomdp-solve or SARSOP, with a given initial belief; (2) compute belief updates by hand or in code for a given action–observation sequence; and (3) interpret a solver's policy graph. Common mistakes: an observation table indexed by (start state) instead of (end state), and probabilities that don't sum to 1 across observations for each state.

Chapter summary

  • MEU: choose \(\arg\max_a \sum_{s'} P(s'|a)U(s')\). The value of information = best EU with info − best EU without.
  • MDP = \((S, A, P, R, \gamma)\) + Markov property. The solution is a policy.
  • Bellman: \(U(s) = R(s) + \gamma \max_a \sum_{s'} P(s'|s,a)U(s')\).
  • Value iteration repeats Bellman updates (a contraction). Policy iteration alternates exact evaluation (linear) and greedy improvement. LP: primal over \(V\), dual over flows \(x(s,a)\).
  • POMDP adds a sensor model \(P(o|s)\). Act on the belief \(b\), updated by \(b'(s') = \alpha P(o|s')\sum_s P(s'|s,a)b(s)\).
Bolt's next problem

All of this assumed someone handed Bolt the model: transition probabilities, sensor accuracies, rewards. Where do such models come from? From data. Next, Bolt learns interpretable rules from examples with decision trees, and then learns whole probabilistic models with Bayesian networks.