It’s almost been half a year since I first decided to kick off this RL notes series. I apologize for the delay – I’ve been busy with other work, or honestly, just lacking persistence :( Also I have to say I struggled a bit to write my last post on the topic of MAB since the math is quite tough :(
Anyway, let’s continue the journey of RL with the well-known MDP – Markov Decision Process.
Define history ht=(o0,a0,r1,o1,a1,r2,…,ot).
In a general RL process, the agent will take an action at based on the full history ht, and then recevie a new reward rt+1 and observe a new ot+1.
However, modeling based on the full history is often intractable. If we can find a function f such that st is a sufficient statistic of the history for predicting future, then:
Pr(ot+1,rt+1∣ht,at)=Pr(ot+1,rt+1∣st,at)
In this case, st is a Markov state.
If ot itself is already a sufficient statistic of the history (i.e., the system is fully observable), we can simply pick st:=ot, which leads to the Markov Property:
Definition: Markov Property
Assume that the state st contains all the useful information in history ht. Then we have:
Pr(st+1,rt+1∣st,at)=Pr(st+1,rt+1∣ht,at)
One example that satisfies the Markov Property is a board game. It’s enough to decide the next move once we know the current board. We don’t care about how the current state was reached. On the contrary, we cannot predict the direction of a ping-pong ball from a single video frame. We have to know more previous frames, which doesn’t satisfy the standard Markov Property. Hence, the Markov Property is actually a simplification of real scenarios, but it still covers many practical scenarios and makes the math much easier and more elegant.
Markov Decision Process
Perfect! You’ve got the main idea for an MDP now: given the current state and action, the next state and reward do not depend on the earlier history. The final step in defining MDP is to introduce the environment and decision-making process.
Definition: Markov Decision Process
The Markov Decision Process can be represented as a 5-tuple where the states satisfy the Markov Property:
(S,A,P,R,γ)
s.t.
Pr(st+1,rt+1∣st,at)=Pr(st+1,rt+1∣ht,at)
S: the state space.
A: the action space.
P: the transition dynamics, where P(s′∣s,a)=Pr(St+1=s′∣St=s,At=a) represents the probability of reaching state s′ from state s after taking action a.
R: the reward function, where R(s,a,s′)=E[Rt+1∣St=s,At=a,St+1=s′] represents the expected reward obtained when transitioning from state s to state s′ after taking action a.
γ: the discount factor which belongs to [0,1].
For the notation R, it is kind of confusing whether it is part of the MDP or a random variable standing for reward. For our discussion, R(s,a,s′) with brackets corresponds to the former, while Rk with a subscript corresponds to the latter.
The Markov Property is exactly what allows us to define P(s′∣s,a) and R(s,a,s′) using only the current state-action pair, instead of the whole history.
Bellman Equation
As we talked about in the first post, the goal of RL is to find the states with highest value. So it’s crucial to consider the values in the MDP.
A key feature of MDPs is their recursive structure, as shown above. Thus, we aim to express the value functions recursively. Before formal discussion, let’s define a new notation to simplify the discussion:
Definition: (Discounted) Return
The (discounted) return is a random variable representing the discounted cumulative reward along a trajectory.
Gt=k=t+1∑Tγk−t−1Rk
Here T is the terminal time for an episodic task; for a continuing task, we may take T=∞.
Remove all notations with time subscripts, we have the Bellman Equation.
Definition: Bellman Equation
v(s)=a∑π(a∣s)s′∑P(s′∣s,a)[R(s,a,s′)+γv(s′)]
Let’s take an example of the Bellman Equation to better understand it.
Example: Bellman Equation
Cells with number have given values. The arrows on the left indicate the reward for each move. Hitting a wall yields a reward of −1 and the agent remains in the same position. All other moves yield zero rewards. Actions are chosen uniformly at random. γ=0.9.
Compute the values for the two highlighted cells on the right.
It’s easy to see the P(⋅) are one-hot and all π(a∣s)=0.25. By the Bellman Equation, we have:
Then when γ<1 and v=0, ∥(I−γPπ)v∥∞>0 holds, which means I−γPπ is invertible.
Hence, when γ<1, we can express v as
vπ=(I−γPπ)−1rπ
Conclusions
Congratulations! We’ve covered the most fundamental modeling framework in RL—MDP. In most cases, we will assume that the environment satisfies the MDP assumptions.
It’s necessary to clarify that the matrix-form discussion in this section applies to a finite, or tabular, MDP. We assume that both the state space and the action space are finite and discrete, which allows us to represent the problem using linear algebra.
Takeaways
The main idea for Markov Decision Process is to assume the Markov Property:
Pr(st+1,rt+1∣st,at)=Pr(st+1,rt+1∣ht,at)
Bellman Equation gives a recursive characterization of the value function in an MDP.
v(s)=∑aπ(a∣s)∑s′P(s′∣s,a)[R(s,a,s′)+γv(s′)]
We can express the Bellman Equation in a matrix form to make it more unified and elegant.
vπ=(I−γPπ)−1rπ
In the next post, we will go deeper into a direct utilization of MDP: dynamic programming (DP), which I believe most of you are familiar with from your first programming class at university. However, we will view it in a more RL way, and I believe you may gain a new understanding of it.
Last updated on 2026-09-07
Loading comments…
Comments failed to load. Disqus may be blocked on your network.
Loading comments…
Comments failed to load. Disqus may be blocked on your network.