Exercises — Markov Decision Processes (MDP)
Before we start, three edge-case words get used a lot below — pin them down now so they never blur together:
The two workhorse formulas you will reuse everywhere:
Our running world for several problems is a 4-state line. Look at it once now:

Level 1 — Recognition
Exercise 1.1 (L1)
Which of the following is the correct statement of the Markov property? (a) (b) (c) must be positive.
Recall Solution
(a). The Markov property says the next state depends only on the current state and action, not the full history. Statement (b) is stronger (it says the next state is independent of the current one — false in general). Statement (c) is about rewards, not the Markov property, and rewards can be any real number.
Exercise 1.2 (L1)
An MDP is the tuple . Match each symbol to its role: situations, decisions, randomness of the next situation, immediate payoff, how much future matters.
Recall Solution
- ::: situations (states)
- ::: decisions (actions)
- ::: randomness of the next situation (transition probability)
- ::: immediate payoff (reward)
- ::: how much future matters (discount factor)
Exercise 1.3 (L1)
The discount factor is required to satisfy . Let denote a fixed upper bound on the reward received on every single step (so no step ever pays more than ). Why can't we allow for an infinite-horizon problem in which a reward of exactly arrives every step?
Recall Solution
Here is just "the constant per-step reward" — a single fixed number, not a function of the state. With the return is . The geometric bound divides by , so the sum does not converge. We need so far-away rewards shrink to zero and the total is finite. (Finite-horizon or episodic tasks can use because the sum has finitely many terms.)
Level 2 — Application
Exercise 2.1 (L2)
In the line world above, states . Action right moves one step right (deterministically); at the agent self-loops with reward ; all other rewards are ; ; policy = always right. Compute .
Recall Solution
is an absorbing state (see the definition callout): it self-loops giving forever — the episode does not end, so it is not "terminal". That endless stream is why we get a geometric series: Equivalently .
Exercise 2.2 (L2)
Same world. Compute , , by back-substitution.
Recall Solution
Every step earns reward until the goal, so each state just discounts the state to its right: Check the intuition: is 3 steps from goal, so . ✓
Exercise 2.3 (L2)
Make right stochastic at : it reaches with probability , else stays at (reward ). Keep , . Compute .

Recall Solution
Split the expectation over the two branches (the red arrow is the 0.8 branch that reaches the goal). Note the 0.2 branch is a self-loop back into , so it carries a term: Lower than the deterministic because the self-loop delays reaching the goal.
Level 3 — Analysis
Exercise 3.1 (L3)
At state you may choose (safe): deterministically reach with reward ; or (risky): with prob reach (reward ), with prob reach (reward ). Given . Take here purely to keep the arithmetic clean — this is legitimate because we only compare one-step Q-values with fixed, given downstream values, so no infinite sum and no contraction argument is involved. (For a true infinite-horizon problem you would still need , as in Exercise 1.3.) Which action does pick, and by how much?

Recall Solution
Compute each action-value : Since , , winning by . The red arrow marks the higher expected branch that tips the decision.
Exercise 3.2 (L3)
In Exercise 3.1, how low would the reward for reaching have to drop (call it , replacing ) before the safe action becomes optimal?
Recall Solution
Set : So once the bad outcome is worse than (strictly), safe wins. At exactly both give — a tie, and either is optimal.
Exercise 3.3 (L3)
Explain, using the geometric-series bound, why increasing from to makes the goal-state value jump from to , but the ratio actually increases.
Recall Solution
At the goal, . For that is ; for it is . Meanwhile , so the ratio is : it rises from to . A larger discounts the 3-step distance less, so far-away states keep almost the full goal value.
Level 4 — Synthesis
Exercise 4.1 (L4)
Build and solve a 2-state MDP with a genuine loop. States , one action each. From : go to with reward . From : go back to with reward . . Find and .
Recall Solution
Write both Bellman equations (deterministic transitions): Substitute the second into the first: Then . Sanity check: the reward stream from is discounted by : which sums to . ✓
Exercise 4.2 (L4)
Design rewards so that in Exercise 4.1's loop, an agent would prefer to stay looping rather than take a hypothetical third action from that goes to an absorbing state paying a one-time reward and thereafter forever (so ). With , does looping beat leaving? Show the comparison.
Recall Solution
Looping value from is (from 4.1). Leaving: . Since , leaving is better — the one-shot beats the discounted loop. To make looping preferred you'd raise the loop rewards or lower the exit reward; e.g. exit reward gives and looping wins.
Level 5 — Mastery
Exercise 5.1 (L5)
Consider a single state with two actions. Action self-loops with reward ; action self-loops with reward , . Derive in closed form and state .
Recall Solution
Each self-loop is a geometric stream: choosing forever gives . The Bellman optimality equation is Why we can pull out of the : both branches share the identical term (same state , same value). Adding the same constant to two numbers never changes which one is larger, so . Here , giving Solving: , and . The optimal policy just commits to the better constant reward forever.
Exercise 5.2 (L5)
Prove the identity for a deterministic policy, starting only from the two definitions and .
Recall Solution
Substitute directly into the definition of : The right-hand side is character-for-character the definition of . Hence . In words: the value of a state is exactly the value of taking the action your policy prescribes there, then continuing under .
Exercise 5.3 (L5)
Value-iteration flavour. In the deterministic line world (Ex 2.1–2.2, ), start with for all states and apply one sweep of the Bellman optimality update using . Give . Which state's estimate is already correct after one sweep?
Recall Solution
With , only immediate rewards survive one sweep:
- Only (the absorbing goal, which has a non-zero immediate reward) has a non-zero estimate. Reward information "spreads backward" one step per sweep — after enough sweeps it reaches . This is exactly how 5.4.01-Q-Learning and value iteration propagate value; see 5.1.04-Bellman-Equations.
See also: 5.1.03-Policy-and-Value-Functions, 5.3.01-Monte-Carlo-Methods, 5.3.02-Temporal-Difference-Learning, Markov-Chains.