A Markov decision process is the mathematical scaffolding of sequential decision making under uncertainty. An agent lives in a world of states, chooses actions, receives rewards, and moves to new states, and it wants to maximize long run reward. Every reinforcement learning problem I have worked on, from tank battles to chess to Minecraft, is at bottom an MDP, and the reason the abstraction is worth learning carefully is that once a problem is written as one, the entire theoretical toolkit applies to it: recursive value equations, dynamic programming, convergence guarantees, and the sample based methods that come later.
The word Markov does the heavy lifting. It means the future depends on the past only through the present state. Whatever happened before is already baked into where you are now, so a decision only ever needs to look at the current state. That single assumption is what makes the recursion in the next note possible, and when it fails, most of the guarantees fail with it.
Formal definition
An MDP is a tuple :
- , the state space, the set of all configurations the environment can be in.
- , the action space, the set of actions the agent may take. This may depend on the state, written .
- , the transition kernel, the probability of landing in after taking action in state . For each this is a probability distribution over , so .
- , the reward function, the expected immediate scalar reward for taking in . Some texts write and let the reward depend on the landing state too; the two are interchangeable by taking .
- , the discount factor, which controls how future reward is weighed against immediate reward.
Throughout this folder I take and finite and rewards bounded, . Almost everything extends to countable or continuous spaces with measure theoretic care, but the finite case is where the proofs are cleanest and it already contains every idea.
The Markov property
The defining assumption is that the next state and reward depend on the history only through the current state and action:
The state is a sufficient statistic for the future. If the thing you are calling the state does not satisfy this, you are really working with a partially observable MDP, and the honest fix is to augment the state until it does: include velocity if you only had position, include the last few frames if a single frame is ambiguous, include a memory if the environment has hidden structure. The theory below assumes the augmentation has been done.
Trajectories, returns, and policies
Interaction generates a trajectory
where is drawn from a start distribution , each action is chosen by the agent, and each is drawn from the environment given .
The discounted return from time is
The return satisfies a recursion that the whole subject is built on:
A policy maps states to distributions over actions, . A policy is deterministic if it puts all its mass on one action, in which case I write . A policy is stationary if it does not depend on . For discounted infinite horizon problems, stationary policies are enough, which is one of the results below.
Why discount
The discount factor is usually introduced as a modeling choice, a preference for reward now over reward later, and it is that. But it is also doing mathematical work, and both roles matter.
Convergence. With bounded rewards and , the return is an absolutely convergent series:
Without the discount, an infinite horizon sum of rewards need not converge at all, and comparing two policies whose returns are both infinite is meaningless. The bound shows up constantly in the proofs in this folder; it is the reason value functions live in a bounded set.
Contraction. In Bellman equations the same becomes the contraction constant of the Bellman operator. Every convergence rate in this folder is a power of , and the closer is to one, the slower everything converges. That is the real cost of a long effective horizon.
Effective horizon. A useful way to read is that the agent effectively cares about roughly steps into the future. At that is a hundred steps; at it is ten.
Value functions
The state value function of a policy is the expected return starting from and following :
The action value function, or Q function, conditions on the first action as well:
The subscript on the expectation means that all actions after the conditioning are drawn from and all transitions from . Because the policy is stationary and the dynamics are Markov, neither quantity depends on , which is why I can write them as functions of alone.
The two are linked in both directions. Averaging over the policy's action choice gives :
Taking one step and then averaging over the landing state gives :
This second identity is the seed of the Bellman equation. Substituting one into the other produces the recursion that the next note is about.
Both value functions inherit the bound from the return: and likewise for .
Matrix form of the value function
For a fixed policy on a finite state space, everything is linear algebra. Let be the vector of state values, the vector of expected immediate rewards under the policy,
and the policy induced transition matrix,
is row stochastic: every entry is nonnegative and every row sums to one. The value function satisfies
which is the Bellman expectation equation in matrix form, and it can be solved directly:
Why the inverse exists. Since is row stochastic, , so . The Neumann series then converges,
and reading that series term by term gives back the definition of the value function: is the discounted expected reward steps in the future. The matrix inverse and the infinite sum are the same object, which is a nice check that the algebra means what it should.
Optimality
The optimal value functions are the best achievable over all policies:
A policy is optimal if for every state simultaneously. It is not obvious that such a policy exists. The supremum is taken state by state, and a priori the policy that is best from one state might be different from the policy that is best from another.
The foundational result is that for a finite discounted MDP an optimal policy does exist, and it can be taken deterministic and stationary. You never need randomness or memory to act optimally. The proof goes through the Bellman optimality equation and is given in Bellman equations: is the unique fixed point of the optimality operator, and any policy that is greedy with respect to achieves it in every state at once.
One consequence worth stating plainly: a partial order on policies, if for all , has a maximum element. That is unusual for a partial order and it is special to MDPs.
Variants
- Finite horizon. The return runs to a fixed and the discount can be dropped. The optimal policy is generally not stationary, because the right action with three steps left differs from the right action with thirty, and the state has to be augmented with the time index to recover the Markov structure.
- Average reward. With and an infinite horizon, the objective becomes the long run average reward per step. This needs ergodicity assumptions on the chain and its own theory.
- Continuous state and action spaces. Sums become integrals, the transition kernel becomes a density or a measure, and the same equations hold. In the linear dynamics, quadratic cost case they reduce to the Riccati equation of LQR.
- Partial observability. The agent sees an observation that is a noisy function of . The belief state, the posterior over given the history, is itself Markov, so a POMDP is an MDP over beliefs, but the belief space is continuous and high dimensional.
Where this breaks
The two assumptions that do the most work are the Markov property and bounded rewards with . In practice the first is usually violated slightly (the state you have is almost sufficient) and the theory degrades gracefully. The second is violated by any environment with unbounded reward or by the choice without a terminating episode, and there the value function may not exist at all.
The other thing to be honest about is that knowing and is a strong assumption. The next two notes assume it. Temporal difference learning is the point where it is dropped.
References
- Sutton, Barto. Reinforcement Learning: An Introduction, 2nd ed. MIT Press, 2018, chapter 3.
- Puterman. Markov Decision Processes: Discrete Stochastic Dynamic Programming. Wiley, 1994.
- Bellman. Dynamic Programming. Princeton University Press, 1957.