MDP Foundations
The mathematical framework for RL — states, actions, rewards, and the Markov property
What is Reinforcement Learning?
Reinforcement Learning (RL) is a computational approach where an agent learns to make decisions by interacting with an environment. Unlike supervised learning, RL does not require labeled input/output pairs. Instead, the agent discovers optimal behavior through trial and error, guided by reward signals.
The Agent-Environment Loop
The fundamental RL interaction follows a cyclic pattern:
- Agent observes the current state
- Agent selects an action
based on its policy - Environment transitions to a new state
- Agent receives a reward
- Repeat

This loop captures the essence of sequential decision-making: every action influences future states and rewards, requiring the agent to balance immediate rewards against long-term consequences.
Markov Decision Process (MDP)
An MDP provides the formal mathematical framework for modeling RL problems. It defines the rules of the environment the agent interacts with.
Formal Definition
An MDP is defined by the tuple
| Component | Symbol | Description |
|---|---|---|
| State Space | Set of all possible states the environment can be in | |
| Action Space | Set of all possible actions the agent can take | |
| Transition Function | Probability of transitioning to state | |
| Reward Function | Reward received for transition | |
| Discount Factor | How much to weight future rewards vs. immediate rewards |
Transition Dynamics
The transition function
This captures the stochastic nature of many environments — the same action in the same state may lead to different outcomes.
Reward Function Variants
The reward function can take several forms:
: Reward depends on transition : Reward depends on state-action pair : Reward depends only on state
All forms are mathematically equivalent (can be converted to each other).
The Markov Property
The Markov property is the defining characteristic that makes MDPs tractable. It states:
In plain terms: The future depends only on the current state, not on how we got there. The current state contains all relevant information for predicting what happens next.
Why the Markov Property Matters
| Property | Implication |
|---|---|
| Memory-less | No need to store entire history |
| Computational tractability | Dynamic programming becomes possible |
| State sufficiency | State encodes everything needed for optimal decisions |
When Markov Property Fails
Real-world problems often violate the Markov property:
- Partially Observable MDPs (POMDPs): Agent cannot fully observe the state
- History-dependent dynamics: Past actions affect future transitions
Solutions: Augment state with history, use recurrent neural networks, or model as POMDP.
Policies
A policy
Deterministic Policies
A deterministic policy is a function mapping states to actions:
Example:
Stochastic Policies
A stochastic policy defines a probability distribution over actions given a state:
Why stochastic?
- Exploration: Random actions help discover better strategies
- Game theory: Mixed strategies prevent exploitation by opponents
- Continuous action spaces: Often more natural representation
Policy Comparison
| Type | Notation | Use Case |
|---|---|---|
| Deterministic | Exploitation, optimal control | |
| Stochastic | Exploration, adversarial settings |
Episodes vs. Continuing Tasks
RL problems fall into two categories based on their temporal structure.
Episodic Tasks
- Environment resets to initial state after reaching a terminal state
- Interaction naturally breaks into episodes
- Each episode is independent
Examples: Chess games, Atari games, robot manipulation tasks
Continuing Tasks
- No terminal states — interaction continues indefinitely
- Must handle infinite horizon
- Common in control and monitoring systems
Examples: Stock trading, power grid management, recommendation systems
Mathematical Difference
For episodic tasks, the return is:
For continuing tasks, we must use discounting to ensure finite returns:
Return and Discounted Return
The return
Discounted Return Formula
Discount Factor
The discount factor
| Behavior | |
|---|---|
| Myopic: Only immediate reward matters | |
| Balanced: Moderate future consideration | |
| Far-sighted: Values future nearly as much as present | |
| No discounting: Only valid for episodic tasks |

Why Discount?
- Mathematical necessity: Ensures bounded returns for infinite-horizon problems
- Uncertainty: Future is less predictable than present
- Economic preference: Immediate rewards are often preferred (time value)
- Convergence: Helps algorithms converge faster
Recursive Formulation
The return satisfies a useful recursive relationship:
This recursive structure is the foundation for dynamic programming methods like Bellman equations.
GridWorld Example
Consider a 4x4 grid where an agent navigates to a goal state:
| Element | Description |
|---|---|
| States | 16 grid cells |
| Actions | Up, Down, Left, Right |
| Transitions | Deterministic (walls cause stay in place) |
| Rewards | -1 per step, +10 at goal, -10 at trap |
| Discount |
The agent must learn to reach the goal while avoiding traps, minimizing steps taken.
Interview Questions
Q1: "Explain the Markov property and why it's important for RL."
The Markov property states that the future state depends only on the current state and action, not on the history of how we arrived at the current state:
Why it matters:
- Computational tractability: We only need to track the current state, not the entire history
- Enables dynamic programming: Bellman equations and value iteration rely on this property
- State sufficiency: The optimal policy depends only on the current state
When it fails: In partially observable environments (POMDPs), the agent cannot see the full state. Solutions include maintaining belief states or using recurrent networks to encode history.
Q2: "What role does the discount factor play, and how do you choose it?"
The discount factor
determines how much future rewards are weighted relative to immediate rewards: Key roles:
- Mathematical: Ensures convergence for infinite-horizon problems (geometric series)
- Behavioral:
makes agent myopic; makes it far-sighted Choosing
:
- Episodic tasks: Often
or - Continuing tasks: Must be
for bounded returns - Fast-changing environments: Lower
(e.g., 0.9) emphasizes near-term - Long-term planning: Higher
(e.g., 0.999) Practical tip: Start with
, adjust based on task horizon.
Q3: "Compare deterministic vs. stochastic policies. When would you use each?"
Deterministic policy
: Maps each state to exactly one action. Stochastic policy
: Defines a probability distribution over actions for each state.
Aspect Deterministic Stochastic Exploration No inherent exploration Natural exploration via randomness Optimality Sufficient for most MDPs Required for some POMDPs Game theory Exploitable Mixed strategies can be optimal Implementation Simpler More complex (sampling required) Use deterministic when:
- Deploying a trained policy (exploitation)
- Full observability and no adversaries
Use stochastic when:
- Training (exploration is essential)
- Multi-agent or adversarial settings
- Partially observable environments
Quick Reference Card
MDP COMPONENTS
────────────────────────────────────────────────────────
S (States) Set of environment configurations
A (Actions) Set of agent choices
P(s'|s,a) Transition probability function
R(s,a,s') Reward function
γ (gamma) Discount factor [0,1]
MARKOV PROPERTY
────────────────────────────────────────────────────────
P(S_{t+1}|S_t,A_t,...,S_0) = P(S_{t+1}|S_t,A_t)
Future depends only on current state, not history
POLICIES
────────────────────────────────────────────────────────
Deterministic: π(s) = a
Stochastic: π(a|s) = P(A=a|S=s)
RETURN
────────────────────────────────────────────────────────
Episodic: G_t = Σ R_{t+k+1}
Discounted: G_t = Σ γ^k R_{t+k+1}
Recursive: G_t = R_{t+1} + γ G_{t+1}
DISCOUNT FACTOR γ
────────────────────────────────────────────────────────
γ = 0: Myopic (only immediate reward)
γ = 0.9: Standard starting point
γ = 0.99: Far-sighted
γ = 1: No discount (episodic only)
TASK TYPES
────────────────────────────────────────────────────────
Episodic: Terminal states, finite episodes
Continuing: No termination, infinite horizonKey Takeaways
MDPs formalize sequential decision-making with states, actions, transitions, rewards, and discount factor.
The Markov property is foundational — it enables efficient algorithms by ensuring the current state contains all relevant information.
Discount factor
balances present vs. future — lower values emphasize immediate rewards, higher values encourage long-term planning. Policies define agent behavior — deterministic for exploitation, stochastic for exploration and adversarial settings.
Understanding MDPs is prerequisite for value functions, Bellman equations, and all RL algorithms covered in subsequent modules.