All lessons in World Models: Learn, Generate, Plan, and Evaluate
Reason with Hidden State
Use history and a belief to distinguish situations that look identical.
30 minutes · Free lesson
What you will learn
- Construct two hidden states that share an observation but need different actions.
- Update a simple belief with measurement evidence.
- Explain why averaging hidden possibilities can produce an unsafe decision.
A camera tells you the cart is at the target. That sounds like success until you notice it may be passing through the target at high speed. A single position measurement cannot tell you which way to brake. The missing information is part of the control problem, even if the next-position regression runs without errors.
The goal is to represent uncertainty about the current situation before predicting the future. Do not replace missing knowledge with an unjustified value of zero.
Show why the observation is insufficient
Consider two states: x = 0, v = -1 and x = 0, v = 1. Both produce position observation zero. With no push and no noise, their next positions are -0.23 and 0.23. A position-only deterministic predictor must return the same answer for both inputs, so it cannot be correct for both.
This is observation aliasing: distinct relevant situations share the same observation. It can arise from hidden velocity, an occluded object, an unseen contact condition or a delayed sensor. Increasing model size does not recover information that the input never contained. History or an additional sensor may distinguish the cases; sometimes uncertainty remains irreducible from available observations.
Use a belief rather than inventing a state
A belief update has two stages. Predict how previous possibilities move under the executed action. Then weight those possibilities by how well they explain the new observation and normalize. This is distinct from merely storing a long sequence: the representation must retain the information relevant to future prediction and action.
Worked example
Update a two-state belief
- Before observing motion, assign probability 0.5 to v = -1 and 0.5 to v = 1.
- A noisy sensor reports positive motion. Its likelihood is 0.1 under negative velocity and 0.9 under positive velocity.
- Multiply prior by likelihood: the unnormalized masses are 0.05 and 0.45. Their sum is 0.50.
- Normalize to obtain probabilities 0.1 and 0.9. The posterior mean velocity is -1 × 0.1 + 1 × 0.9 = 0.8.
- Positive motion is likely, but negative motion remains possible. Retain that distinction if choosing the wrong braking direction is costly.
Run python3 experiments.py belief --out .work/belief.json, then python3 worlds.py inspect .work/belief.json. Confirm that the probabilities sum to one and the reported mean is 0.8. This is an analytic teaching example, not a learned perception system.
Distinguish a mean from a plausible state
The original equal-weight belief has mean velocity zero. Neither possible hidden state has velocity zero. Treating the mean as known would tell the controller to coast at exactly the moment it should investigate or brake. Mean predictions can be useful under particular quadratic objectives, but that convenience does not make the mean a complete uncertainty representation.
A practical controller might request another observation, act conservatively, or evaluate candidate actions over multiple plausible states. Which choice is useful depends on the cost of delay, measurement accuracy and the consequences of a wrong action. Write that tradeoff explicitly instead of labeling all uncertainty a reason to stop.
Test what history contributes
Two position measurements separated by a known time interval allow a finite-difference velocity estimate. With the course's updated-velocity position rule, the displacement over the preceding interval identifies the velocity used during that interval in the noiseless case. Measurement noise and latency complicate the estimate; closer timestamps do not automatically make it more accurate because dividing by a smaller interval also amplifies position noise.
Latent state-space models can combine recurrent context and stochastic state; PlaNet is a primary example. The useful question here is whether the representation distinguishes histories that lead to different outcomes, not whether its internal state has a familiar physical label.
Exercise
A position-only model predicts next position zero for equally frequent velocities -1 and 1 at x = 0. Is it necessarily a bad least-squares fit? Is it a sufficient control state?
Check your answer
Zero is the conditional mean and can be the best squared-error point prediction for that ambiguous input. It is not a sufficient control state because the two cases require different braking actions and have different next positions. Retain history or a distribution over possibilities.
Exercise
Change the prior probability of positive velocity to 0.2 while keeping the sensor likelihoods 0.9 and 0.1. Calculate the posterior probability of positive velocity.
Check your answer
The positive mass is 0.2 × 0.9 = 0.18; the negative mass is 0.8 × 0.1 = 0.08. The posterior positive probability is 0.18 / 0.26, approximately 0.6923. The same measurement produces a different posterior when prior evidence differs.
Summary
A partial observation can hide distinctions that matter for action. Use history and measurement evidence to maintain relevant possibilities, and avoid treating an average as a fully observed state.
Next action
Store experience with enough timing, episode and observation information to reproduce these distinctions.