14.1 Time and Uncertainty
Temporal reasoning represents evolving state variables, transitions, and observations. A filtering system estimates the current state from evidence available so far.
AI · Uncertain knowledge and reasoning
Temporal models combine state transitions with noisy observations. Add observations one at a time and see a hidden-state belief update by forward filtering.
Temporal reasoning represents evolving state variables, transitions, and observations. A filtering system estimates the current state from evidence available so far.
Filtering updates beliefs as each new observation arrives; prediction projects beliefs forward, and smoothing revises past-state estimates using later evidence.
An HMM has a Markov hidden state and observations conditionally independent given that state. The forward algorithm alternates transition prediction and emission reweighting.
For linear systems with Gaussian noise, Kalman filtering efficiently updates a continuous state estimate and its uncertainty.
Dynamic Bayesian networks describe dependencies within a time slice and across successive slices; compact repeated structure can model many variables over long sequences.
HMM forward filtering
Hidden weather is Sunny or Rainy. Transitions: P(Sunny′|Sunny)=.8 and P(Sunny′|Rainy)=.3. Umbrella likelihoods are .1 in sun and .8 in rain.
Each update first predicts with the transition model, then multiplies by the observation likelihood and normalizes. These are filtering beliefs, not smoothed past estimates.
Let K be the number of hidden states and T the number of observations. A dense HMM prediction sums over previous states for each next state, O(K²) per observation; likelihood weighting and normalization add O(K). Thus standard filtering takes O(T·K²) time and O(K) auxiliary memory when only the current belief vector is retained (O(T·K) if all belief vectors are saved).
This demo fixes K = 2, so the filtering arithmetic is O(1) per observation and O(T) across T observations, with O(1) belief-state workspace. The implementation also stores all observations (O(T)) and rebuilds their history list each time: UI rendering is O(T) per addition and O(T²) cumulatively, while its retained history/DOM uses O(T) memory. This distinction keeps visualization cost separate from the two-state filter itself. The model assumes a first-order Markov transition and the stated fixed transition/emission probabilities.