TL;DR
A Markov decision process (MDP) is the standard mathematical model for a decision maker acting over time in a world that is partly random. At each step the agent sees a state, picks an action, receives a reward, and the world moves to a new state according to probabilities that depend only on the current state and the action taken. Choosing well means picking actions that earn the most reward over the long run, not just right now.
The name combines two ideas. The world is a Markov chain once the agent's choices are fixed, so the future depends only on the present. The "decision" part adds the agent, whose actions steer the chain.
Where you'll see it: in reinforcement learning, where game-playing agents, robot controllers and the fine-tuning of language models are all framed as MDPs, and in inventory, pricing and maintenance planning.
Intuition
A game of states, moves and rewards
Imagine a delivery robot in a small warehouse. Its state is where it is and how much battery it has. Each step it chooses an action: move left, move right, or recharge. Moving costs a little energy, recharging costs time, and delivering a parcel pays a reward. Where the robot ends up is partly random, because the floor is slippery and the wheels sometimes slide.
The MDP is the bookkeeping for this story. It names the possible states, the possible actions, the chance of each outcome, and the reward. It gives no answer by itself. It only says what the problem is, so that a method can search for a good plan.
Why the Markov part matters: if the state already records the battery level and the position, then knowing the whole history of the robot adds nothing to predicting what happens next. The state is a summary of everything relevant. That summary is what makes planning possible. Without it, the robot would have to remember every past move before it could decide, and the problem would balloon.
The key trade-off is between now and later. Recharging now costs a reward, but it keeps the robot alive for the deliveries that come after. A good policy has to see that link, which is why the reward is summed over time rather than read off one step at a time.
flowchart LR A[State A] -- "go, reward 1" --> B[State B] A -- "stay, reward 0" --> A B -- "stay, reward 2" --> B B -- "go, reward 0" --> A
The diagram is the smallest interesting MDP: two states, two actions each. Arrows show which state each action leads to. The worked example below uses exactly this one.
The math
Definition
A Markov decision process is a tuple , where
- is the set of states,
- is the set of actions (in some states only a subset is allowed, which we ignore here),
- is the probability that the next state is when the agent takes action in state ,
- is the expected reward received for taking action in state ,
- is the discount factor.
Read the bar in as "given that". The probabilities for each state and action must add to 1 over , just like the rows of a Markov chain transition matrix. The Markov property is built in: looks only at and , never at the earlier history. Removing the actions leaves a plain Markov reward process; fixing a rule for choosing actions also leaves one.
A rule for choosing actions is called a policy . A deterministic policy maps each state to one action, . A stochastic policy gives a probability for each action. Fixing turns the MDP into a Markov chain on states, with transition probabilities .
Return and the discount factor
The quantity to maximise is the return, the discounted sum of future rewards starting from time :
A reward steps in the future is worth of its face value today. With , a reward ten steps away counts for about 35 percent of itself; with , it counts for about 0.1 percent. The discount keeps the infinite sum finite when rewards are bounded, and it expresses a preference for sooner over later. Since , the geometric series converges to at most when every reward is at most .
- gamma = 0.9
- gamma = 0.5
The value function
The value of a state under a policy is the expected return when starting there and following :
The expectation (see Expected Value) is over the randomness in the policy and the transitions. Because the return from onwards has the same form as the return from , the value satisfies a recursion. Splitting off the first reward and the first transition gives
This is the Bellman expectation equation. It says the value of is the average, over actions and next states, of the immediate reward plus the discounted value of where you land. The optimal value satisfies the same idea with a maximum over actions, the Bellman optimality equation:
Solving this system tells you the best achievable value in every state, and reading off the maximising action in each state gives an optimal policy.
Two solution methods
Value iteration applies the right-hand side repeatedly, starting from any guess , and is the result of one sweep. Because the update is a contraction with factor , the error shrinks by at least that factor each sweep. Policy iteration instead evaluates a fixed policy exactly (a linear system), then improves the policy greedily, and repeats. Both reach the optimum for finite MDPs.
Worked examples
Take the diagram above with . In state A, "stay" gives reward 0 and keeps you in A, while "go" gives reward 1 and moves you to B. In state B, "stay" gives reward 2 and keeps you in B, while "go" gives reward 0 and moves you to A. Everything is deterministic, so is just 0 or 1.
- Guess a policy: in B stay, in A go. Then the value of B is , so .
- In A, going to B gives .
- Check the guess. In A, "stay" would give , which is less than 3, so "go" is right. In B, "go" would give , less than 4, so "stay" is right.
- The guess is consistent with the Bellman optimality equation, so and .
Now run value iteration from to see the convergence. Each sweep applies both maxima.
- Sweep 1: and .
- Sweep 2: and .
- Sweep 3: and .
- Sweep 4: and .
The distance from B's optimal value 4 is 2, 1, 0.5, 0.25 after each sweep: it halves every time, which is the factor at work. Interpretation: the optimal plan is to walk to B once and then sit there collecting 2 per step. Staying in A forever would pay 0 at every step, so leaving is always better.
A streaming service has two customer states: Free (F) and Paid (P). From Paid, a customer pays 10 per month and cancels with probability 0.2 each month. From Free, a customer earns nothing. Each month the service can either "nudge" (an email campaign that costs 1 per free customer) or "hold" (do nothing). A nudge converts a Free customer with probability 0.3 instead of 0.1. Paid customers are unaffected by the choice. Use .
Transition probabilities and rewards:
| State | Action | Next state | Probability | Reward |
|---|---|---|---|---|
| F | nudge | P | 0.3 | -1 |
| F | nudge | F | 0.7 | -1 |
| F | hold | P | 0.1 | 0 |
| F | hold | F | 0.9 | 0 |
| P | any | P | 0.8 | 10 |
| P | any | F | 0.2 | 10 |
Compare two fixed policies. Each is a Markov chain with rewards, so the value satisfies a linear system .
- Policy "always nudge". Write and for the two values. Then and .
- Rearrange the first: . Rearrange the second: .
- Substitute. The solution is and .
- Check: , and .
- Policy "always hold". The same steps give and , so .
Interpretation: nudging costs 1 a month while a customer is free, but it nearly doubles the value of a free customer (44 against 24.3). It also lifts the value of a paid customer (64 against 51.35), because a paid customer who cancels becomes a free customer who can be won back. The total value is higher under nudging in both states, so a policy that nudges free customers dominates. These are the only two deterministic policies, so nudging is the optimal policy here. The same machinery that solved the toy problem answers a yes-or-no business question.
Tradeoffs and failure modes
An MDP is the right model when the problem has actions that change the state, outcomes that are random, and a reward that depends on a sequence of choices. It is the wrong model when the agent cannot see the state, when the transition probabilities are unknown and cannot be learned, or when the reward is only known at the end and cannot be attributed to earlier steps.
| Situation | Problem | Better choice |
|---|---|---|
| The agent sees only part of the state (for example, a camera) | The Markov property fails; the observation is not enough to predict the future | Partially observable MDP, or a recurrent policy that keeps memory |
| The model and are unknown, but you can act and observe | Dynamic programming needs and | Model-free reinforcement learning such as [[q-learning |
| The state or action space is huge (images, text) | Tables of values cannot be stored | Function approximation, such as a neural network for the value or the policy |
| The reward is rare and far in the future | Learning is slow and noisy | Shaped rewards, or a discount that is closer to 1 with more samples |
| The discount is too small (for example 0.5) | The agent ignores consequences a few steps away | Raise toward 0.99 for long-horizon tasks |
| The reward is sometimes the wrong proxy (for example clicks) | The agent learns to game the proxy | Revisit the reward; treat it as part of the design, not a fixed fact |
A common failure in practice is an agent that is perfectly optimal for the MDP you wrote down and useless for the world you meant. The model is only as good as its states, probabilities and rewards. Check each assumption before trusting the policy.
History
The formal model comes from operations research. Richard Bellman introduced the dynamic-programming approach to sequential decisions in the early 1950s, and in 1957 he wrote a paper on what he called a Markovian decision process, presenting the optimality equation that now carries his name. The problem he was solving was how to plan multi-stage decisions under uncertainty, such as the stock of a warehouse or the routing of a process, where the same subproblems came back again and again.
Ronald Howard followed in 1960 with a book that introduced policy iteration, a method that alternates between evaluating a policy and improving it. That gave the field its practical algorithms. Martin Puterman's 1994 textbook is the standard reference for the theory of discounted and infinite-horizon problems.
The model entered machine learning through reinforcement learning. Chris Watkins's 1989 thesis on learning from delayed rewards connected the MDP to learning without a known model, which led to Q-learning. Richard Sutton and Andrew Barto's textbook made the MDP the common language of the field, and later work combining these ideas with deep networks made it central to modern game-playing and control agents.
Check yourself
QuestionIn an MDP, what does the Markov property say about the transition probabilities ?Show answer
It says the probability of the next state depends only on the current state and the action . The earlier history of states and actions adds nothing once and are known. That is what lets the model be written as one table of probabilities, and what makes the dynamic-programming equations valid.
QuestionWith , what weight does a reward received 5 steps in the future get in the return? Give a number to two decimal places.Show answer
The weight is . Computing it step by step: , , , . So the weight is about 0.59.
QuestionIn the two-state toy problem, why is 'stay in A' never optimal even though it costs nothing?Show answer
Staying in A gives reward 0 forever, so its value is , which can only be 0 if is 0. Going to B gives reward 1 once and then reward 2 per step thereafter, which is worth 3 from A. Any positive reward available later beats a permanent zero, so the optimal action in A is to go.
QuestionWhy might a designer choose a larger discount factor, say 0.99, rather than 0.5 for a long-running robot?Show answer
A larger keeps distant rewards meaningful. With 0.5, rewards more than a few steps away are almost ignored, so the robot would never plan to recharge early or to pursue a delivery that takes many moves. With 0.99 the same rewards still count substantially, which matches a task whose payoff depends on a long sequence of actions. The cost is that learning and planning take longer, because the effective horizon is about steps, here 100.
QuestionA subscription firm's model says a nudge always pays off, but the firm's actual nudges have a 0.1 chance of conversion. What should the firm check before trusting the MDP policy?Show answer
It should check the transition probabilities against data. The policy's value depends directly on the conversion probability in the model, so if the model assumed 0.3 and reality is 0.1, the nudge's advantage may vanish or reverse. The firm should estimate the conversion rate from a controlled test, rerun the policy evaluation with the measured value, and see whether the ranking of the two policies changes.