Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Finite Markov decision processes

Finite Markov decision processes (MDPs): definitions, Bellman expectation and optimality equations, conditions for uniqueness and convergence, worked numerical examples, and exam guidance.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Finite Markov decision processes (MDPs) give the mathematical model for sequential decision-making under uncertainty when the state and action sets are finite. An engineer uses finite MDPs to formalise problems where an agent must choose actions over time to maximise cumulative reward — e.g., robotics navigation in a discretised environment, resource allocation, or designing reinforcement-learning algorithms (value iteration, policy iteration, Q-learning).

Key ideas

  • Policy π — a (possibly stochastic) mapping from states to a probability distribution over actions. For finite action set A(s) available in state s, π(a | s) is the probability of selecting action a in state s. A policy is deterministic if for every s there is a single a with π(a | s) = 1.

  • Return G_t — the total discounted reward from time t: G_t = R_{t+1} + γ R_{t+2} + γ^2 R_{t+3} + ... . This is well-defined for γ < 1; for γ = 1 it is well-defined only for episodic tasks that terminate almost surely under the considered policy.

  • State-value function vπ(s) — the expected return when starting in state s and following policy π thereafter. Definition (exact): vπ(s) = Eπ[G_t | S_t = s]. Units: same as reward units.

  • Action-value function qπ(s,a) — the expected return when starting in state s, taking action a, and thereafter following π: qπ(s,a) = Eπ[G_t | S_t = s, A_t = a]. It relates to the state-value by vπ(s) = Σ_a π(a | s) qπ(s,a). The action-value also satisfies the Bellman expectation equation: qπ(s,a) = Σ_{s',r} p(s', r | s, a) [ r + γ Σ_{a'} π(a' | s') qπ(s',a') ].

  • Derivation of the Bellman expectation equation (step-by-step):

    1. Start from definition: vπ(s) = Eπ[G_t | S_t = s] = Eπ[R_{t+1} + γ G_{t+1} | S_t = s].
    2. Linearity of expectation: vπ(s) = Eπ[R_{t+1} | S_t = s] + γ Eπ[G_{t+1} | S_t = s].
    3. Expand using the law of total expectation over actions and next states: vπ(s) = Σ_a π(a | s) Σ_{s',r} p(s', r | s, a) [ r + γ vπ(s') ].
    4. This is the Bellman expectation equation; it gives a system of |S| linear equations when π is fixed and |S| is finite.
  • Bellman optimality equation (exact): the optimal value function v*(s) (the maximum achievable expected return from s) satisfies v*(s) = max_a Σ_{s',r} p(s', r | s, a) [ r + γ v*(s') ]. The optimal action-value function q*(s,a) satisfies q*(s,a) = Σ_{s',r} p(s', r | s, a) [ r + γ max_{a'} q*(s',a') ].

  • Existence and uniqueness: for finite S and A and γ ∈ [0,1), the Bellman expectation operator (for fixed π) and the Bellman optimality operator are contraction mappings in the sup-norm with contraction factor γ. Therefore, there is a unique fixed point vπ (respectively v*) and iterative methods (policy evaluation for vπ, value iteration for v*) converge geometrically. If γ = 1, convergence requires additional assumptions (episodic tasks or proper policies); do not assume convergence automatically. Moreover, for discounted finite MDPs there exists at least one optimal deterministic stationary policy π*, and any optimal policy is greedy with respect to v* (equivalently, v*(s) = max_a q*(s,a)).

  • Algorithms that follow from these equations: policy evaluation (solve linear system or perform iterative policy evaluation), policy iteration (alternate policy evaluation and greedy policy improvement), and value iteration (apply Bellman optimality backup repeatedly). These are the finite-MDP foundations for many RL methods (refer to later topics like policy iteration, value iteration, temporal-difference methods, and Q-learning).

  • Diagram to draw in an exam when asked to illustrate a finite MDP: Draw nodes representing states S1, S2, S3. From each node draw arrows for actions (label each arrow with action name). On each arrow write: transition probabilities to next nodes (e.g., 0.7 to S2, 0.3 to S3) and the expected immediate reward on taking that action (e.g., +5). If reward depends on destination state, label each outgoing arrow segment with (probability, reward). Also show policy probabilities at a state as small labels near outgoing arrows: π(a1|S1)=0.6, π(a2|S1)=0.4.

Formulas

p(s', r | s, a) — probability of next state s' and reward r given current state s and action a; unit: unitless; applies in finite MDP modelling transitions.

π(a | s) — probability of selecting action a in state s under policy π; unit: unitless; applies for stochastic policies.

G_t = R_{t+1} + γ R_{t+2} + γ^2 R_{t+3} + ... — return starting at time t; units: same as reward (e.g., joule) if reward has physical units; applies for discounted infinite-horizon or until termination.

v_π(s) = E_π[G_t | S_t = s] — state-value under policy π; units: reward units; applies for any policy π in finite MDP.

q_π(s,a) = E_π[G_t | S_t = s, A_t = a] — action-value under π; units: reward units. v_π(s) = Σ_a π(a | s) q_π(s,a) — relation between state- and action-values; units: reward units. q_π(s,a) = Σ_{s',r} p(s', r | s, a) [ r + γ Σ_{a'} π(a' | s') q_π(s',a') ] — Bellman expectation equation for action-values.

v_π(s) = Σ_a π(a | s) Σ_{s',r} p(s', r | s, a) [ r + γ v_π(s') ] — Bellman expectation equation; units: reward units; applies when solving values under fixed policy π for finite MDP.

v_*(s) = max_a Σ_{s',r} p(s', r | s, a) [ r + γ v_*(s') ] — Bellman optimality equation; units: reward units; applies to define the optimal value function in finite MDP with γ < 1 (or episodic γ = 1 with termination conditions). Also, v_*(s) = max_a q_*(s,a).

q_*(s,a) = Σ_{s',r} p(s', r | s, a) [ r + γ max_{a'} q_*(s',a') ] — Bellman optimality for action-values.

||T v - T w||_∞ ≤ γ ||v - w||_∞ — contraction property of Bellman operators (T is either expectation or optimality operator); unitless inequality; applies when S is finite and 0 ≤ γ < 1.

Worked examples

Example 1 — Policy evaluation (numerical, step-by-step) Problem: Finite MDP with states A, B, C. Policy π is fixed (actions deterministic so π is implicit). Transitions and rewards:

  • From A: next is B with probability 1, reward r = 5 (units: reward-units).
  • From B: next A with prob 0.5 and reward 2; next C with prob 0.5 and reward 0.
  • From C: terminal (absorbing) with reward 0. Let γ = 0.9. Compute v_π(A), v_π(B), v_π(C).

Step 1: Write Bellman expectation equations: v(A) = 5 + γ v(B). v(B) = 0.5 [2 + γ v(A)] + 0.5 [0 + γ v(C)]. v(C) = 0.

Step 2: Substitute v(C) = 0 and simplify v(B): v(B) = 0.5*(2 + 0.9 v(A)) = 1 + 0.45 v(A).

Step 3: Substitute into v(A): v(A) = 5 + 0.9*(1 + 0.45 v(A)) = 5 + 0.9 + 0.405 v(A) = 5.9 + 0.405 v(A).

Step 4: Solve for v(A): v(A) - 0.405 v(A) = 5.9 -> 0.595 v(A) = 5.9 -> v(A) = 5.9 / 0.595 = 1180 / 119 ≈ 9.915966 (reward-units).

Step 5: Compute v(B): v(B) = 1 + 0.45 * 9.915966 ≈ 1 + 4.462185 = 5.462185 (reward-units).

Step 6: v(C) = 0.

Final answers (rounded): v(A) ≈ 9.91597 reward-units, v(B) ≈ 5.46219 reward-units, v(C) = 0.

Example 2 — Value iteration to find optimal policy (numerical) Problem: Two-state MDP S = {s1, s2}, actions at s1: a (stay in s1, reward 0), b (go to s2, reward 5). State s2 is terminal with reward 0 on self-loop. Transition deterministic. Discount γ = 0.9. Find v* and optimal policy using value iteration, start from v0(s)=0.

Step 1: v0(s1) = 0, v0(s2) = 0. Step 2: v1(s1) = max( 0 + 0.9v0(s1), 5 + 0.9v0(s2) ) = max(0, 5) = 5. v1(s2) = 0. Step 3: v2(s1) = max( 0 + 0.9v1(s1), 5 + 0.9v1(s2) ) = max(0.9*5 = 4.5, 5) = 5. Converged.

Therefore v*(s1) = 5, v*(s2) = 0. Optimal policy: at s1 choose action b (go to s2) because it attains the max.

Example 3 — Model-answer style theory question (long question) Question: "Derive the Bellman optimality equation for v*(s) and explain uniqueness of its solution for a finite MDP with 0 ≤ γ < 1." Model answer (concise): Derivation: v*(s) is the maximum expected return achievable from s. By considering the first action chosen and then acting optimally thereafter, we write v*(s) = max_a E[ R_{t+1} + γ G_{t+1} | S_t = s, A_t = a, then act optimally ] = max_a E[ R_{t+1} + γ v*(S_{t+1}) | S_t = s, A_t = a ] = max_a Σ_{s',r} p(s', r | s, a)[ r + γ v*(s') ].

Uniqueness: Define the Bellman optimality operator T by (T v)(s) = max_a Σ_{s',r} p(s', r | s, a)[ r + γ v(s') ]. For finite S and 0 ≤ γ < 1, T is a contraction in the sup-norm with factor γ because max and expectation preserve the contraction property. Thus by Banach fixed-point theorem there is exactly one fixed point v* and value-iteration v_{k+1} = T v_k converges geometrically to v* from any initial v0.

(End of model answer.)

Common mistakes

  • Forgetting that Bellman expectation gives a linear system for fixed π, but Bellman optimality is nonlinear (max) and leads to dynamic programming methods instead of linear algebra.
  • Solving Bellman linear equations numerically without checking the contraction condition (γ < 1) for convergence guarantees.
  • Mixing up vπ and qπ; remember qπ(s,a) conditions on taking action a first.
  • Writing units incorrectly: probabilities are unitless, values have reward-units; do not treat rewards as probabilities.

For your exam

Types of questions you will see:

  • Definitions: define finite MDP, policy, return, vπ, qπ, Bellman equations.
  • Short notes: explain contraction property, explain difference between expectation and optimality Bellman equations.
  • Derivations: derive Bellman expectation equation from the definition of return; derive Bellman optimality by one-step lookahead.
  • Numericals: policy evaluation by solving linear equations; small value-iteration or policy-iteration examples.
  • Diagrams: draw a small finite MDP and label transitions, rewards, and a policy.

What a full-marks answer includes:

  • Precise definitions with notation.
  • Clear assumptions (finite S and A, discount γ and its range).
  • Step-by-step derivation (show expectation decomposition, law of total expectation, substitution).
  • For numericals: show all algebraic steps, carry units, give final numerical answers with reasonable rounding.
  • For proofs: mention contraction mapping and reason for uniqueness when γ < 1; if γ = 1 mention extra assumptions needed.

Quick check

  1. Define the return G_t in words.
  2. State the Bellman expectation equation for v_π(s) in one line.
  3. What condition on γ guarantees that the Bellman operators are contractions for finite MDPs?

Answers: 1) G_t is the total future discounted reward R_{t+1} + γ R_{t+2} + γ^2 R_{t+3} + ... . 2) v_π(s) = Σ_a π(a|s) Σ_{s',r} p(s',r|s,a)[ r + γ v_π(s') ]. 3) γ ∈ [0,1) (i.e., γ < 1) guarantees contraction for finite MDPs.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?