본문으로 건너뛰기

RL 003

· 약 10분

Markov Property

  • The future is independent of the past given the present state.
  • The current state is sufficient to determine the future, without history.

Markov State

P[St+1St]=P[St+1=sSt=s]P[S_{t+1} | S_t] = P[S_{t+1} = s' | S_t = s]

  • tt: Time step
  • St+1S_{t+1}: Next state
  • StS_t: Current state
  • S1,,StS_1, \ldots, S_t: History (All previous states)

State Transition Probability

Pss=P[St+1=sSt=s]P_{ss'} = P[S_{t+1} = s' | S_t = s]

  • Likelihood or probability of moving from one state ss to another state ss' in the next time step t+1t+1.
  • ss: Markov State
  • ss': Successor State
  • tt: Time step
  • State transition matrix PP defines the transitions probabilities between all states ss to all successor states ss'.

State Transition Matrix

P=s1sn(to state)s1sn[P11P1nPn1Pnn](from state)\mathcal{P} = \begin{array}{rl} & \begin{matrix} \textcolor{red}{\boldsymbol{s_1}} & \textcolor{red}{\boldsymbol{\dots}} & \textcolor{red}{\boldsymbol{s_n}} \end{matrix} \quad \leftarrow \text{(to state)} \\ \begin{matrix} \textcolor{red}{\boldsymbol{s_1}} \\ \textcolor{red}{\boldsymbol{\vdots}} \\ \textcolor{red}{\boldsymbol{s_n}} \end{matrix} & \hspace{-10pt} \begin{bmatrix} \mathcal{P}_{11} & \dots & \mathcal{P}_{1n} \\ \vdots & \ddots & \vdots \\ \mathcal{P}_{n1} & \dots & \mathcal{P}_{nn} \end{bmatrix} \\ \begin{matrix} \uparrow \\[-2pt] \mathclap{\text{(from state)}} \end{matrix} & \end{array}
  • State transition matrix PP defines the transition probabilities between all states ss to all successor states ss'.
  • Probability of moving from state sns_n to s1s_1 is Pn1\mathcal{P}_{n1}.

Math cal

Reinforcement Learning and Math Major Symbols

  • P\mathcal{P}: Transition Probability Matrix
  • S\mathcal{S}: State Space
  • A\mathcal{A}: Action Space
  • R\mathcal{R}: Reward Function
  • L\mathcal{L}: Loss Function
  • N(μ,σ2)\mathcal{N}(\mu, \sigma^2): Normal Distribution
  • D\mathcal{D}: Dataset
  • H\mathcal{H}: Entropy / Hypothesis Space

Markov Process

Markov Chain

  • What is going to be happened next?
  • it goes through a sequence of states overtime.
  • Stochastic Process: The next state St+1S_{t+1} is determined by the current state StS_t and the transition probability matrix PP that exhibits the Markov Property.
  • Current state is independent of the past states.
  • Memoryless: History of states leading up to the current state is not necessary to predict the next/future state.
  • MP: S,P\langle\mathcal{S},\mathcal{P}\rangle, What states comes next?, Observer's Perspective.
  • MRP: S,P,R,γ\langle\mathcal{S},\mathcal{P},\mathcal{R},\gamma\rangle, How good/How much reward is this state in the long run?, Evaluator's Perspective.
  • MDP: S,A,P,R,γ\langle\mathcal{S},\mathcal{A},\mathcal{P},\mathcal{R},\gamma\rangle, What action should I take right now to maximize the long-term reward?, Decision Maker's Perspective.

Pss=P[St+1=sSt=s]\mathcal{P}_{ss'} = P[S_{t+1} = s' | S_t = s]

  • SS: a finite set of states.
  • P\mathcal{P}: a state transition matrix, defines the transitions probabilities from all states ss to all successor states ss'.
  • NO REWARD, NO ACTIONS.

Transition Diagram

Moon Rover Transition Diagram

  • Box: where it ends
  • Arrow: transitions
  • Circle: states
  • Number: probability of transitioning to the state
P=[00.10.50.100.30.40.10.500000.50.50000.5000.20.300.70000.30000001]\mathcal{P} = \begin{bmatrix} 0 & 0.1 & 0.5 & 0.1 & 0 & 0.3 \\ 0.4 & 0.1 & 0.5 & 0 & 0 & 0 \\ 0 & 0.5 & 0.5 & 0 & 0 & 0 \\ 0.5 & 0 & 0 & 0.2 & 0.3 & 0 \\ 0.7 & 0 & 0 & 0 & 0.3 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \end{bmatrix}
  • S1: Calibration Site
  • S2: Mineral Site
  • S3: Water Site
  • S4: Drill Site
  • S5: Alien Remain Site
  • S6: Lander Site

Markov Chain Episode

  • A sequence of states from a starting state to a terminal state.
  • S1,S3,S2,S1,S6S_1, S_3, S_2, S_1, S_6
  • S1,S3,S3,S2,S1,S4,S4,S1,S6S_1, S_3, S_3, S_2, S_1, S_4, S_4, S_1, S_6

Episodic Task vs Continuous Task

FeatureEpisodic TasksContinuing Tasks
TerminationHas a well-defined terminal state (TT)Runs indefinitely without termination (T=T = \infty)
Real-World Examples• Video games (e.g., Super Mario: level clear or death)
• Navigation (reaching destination)
• Board games (e.g., Chess: checkmate/draw)
• Smart thermostat (HVAC temperature control)
• 24/7 industrial robotic process control
• Automated trading & server load management
Execution FlowEnvironment resets to a start state once finishedOperates continuously without automatic resets
  • Episodic Tasks: Tasks with a defined end/terminal state.
  • Continuing Tasks: Tasks without a defined end/terminal state.
  • It may require different MDP formulation and solution methods for each type of task.

Markov Reward Process

Markov Chain + Reward

S,P,R,γ\langle\mathcal{S},\mathcal{P},\mathcal{R},\gamma\rangle

  • SS: a finite set of states.
  • P\mathcal{P}: a state transition matrix (Transition Dynamics)
  • R\mathcal{R}: a reward function to compute expected reward from a state.
    • Rs=E[Rt+1St=s]\mathcal{R}_s = \mathbb{E}[R_{t+1} | S_t = s]
    • In the state ss, how much reward can you expect to get in the next time step?
  • γ\gamma: a discount factor, to balance the immediate and future rewards.
    • γ[0,1]\gamma \in [0, 1]

Reward diagram

Return

Gt=Rt+1+Rt+2++RTG_t = R_{t+1} + R_{t+2} + \cdots + R_T

  • GtG_t: Goal Reward
    • The sum of the rewards received from time step tt.
  • Rt+1,Rt+2,,RTR_{t+1}, R_{t+2}, \ldots, R_T: the sequence of rewards received after time step tt
  • TT: terminal state
  • tt: time step

Discount

  • The present value of future rewards.
  • γ=0\gamma = 0: Myopic evaluation for maximizing immediate reward.
  • γ=1\gamma = 1: Far-sighted/Long-term evaluation for maximizing future reward.

Discounted Return

Gt=Rt+1+γRt+2+γ2Rt+3++γTt1RT=k=0γkRt+k+1G_t = R_{t+1} + \gamma R_{t+2} + \gamma^2 R_{t+3} + \cdots + \gamma^{T-t-1} R_T = \sum_{k=0}^{\infty} \gamma^k R_{t+k+1}

  • GtG_t: Discounted Return
  • γ=1\gamma = 1: Undiscounted Markov Reward Process, if all sequences terminate (like games)

Value Function

v(s)=E[GtSt=s]v(s) = \mathbb{E}[G_t | S_t = s]

  • The expected return from state ss.
  • How much total reward can you expect to get starting from this state?
  • A function returning the expected cumulative reward starting from state ss

Markov Decision Process

Markov Reward Process + Actions(Decisions)

S,A,P,R,γ\langle\mathcal{S},\mathcal{A},\mathcal{P},\mathcal{R},\gamma\rangle

  • SS: a finite set of states.
  • A\mathcal{A}: a finite set of actions.
  • P\mathcal{P}: a state transition matrix
    • Pssa=P[St+1=sSt=s,At=a]\mathcal{P}_{ss'}^a = P[S_{t+1} = s' | S_t = s, A_t = a]
  • R\mathcal{R}: a reward function
    • Rsa=E[Rt+1St=s,At=a]\mathcal{R}_s^a = \mathbb{E}[R_{t+1} | S_t = s, A_t = a]
  • γ\gamma: a discount factor

MDP

Policy

π(as)=P[At=aSt=s]\pi(a | s) = P[A_t = a | S_t = s]

  • Policy specifies what actions to take in each state.
    • π(leftwall)=0.8\pi(\text{left} | \text{wall}) = 0.8
    • π(rightwall)=0.2\pi(\text{right} | \text{wall}) = 0.2
    • π(straightwall)=0.0\pi(\text{straight} | \text{wall}) = 0.0
    • The agent's playbook for any given state.
  • It fully defines the behavior of the agent.
  • MDP's policy does not depends on history, only on the current state.

Value Function of a Policy

vπ(s)=Eπ[GtSt=s]v_\pi(s) = \mathbb{E}_{\pi}[G_t | S_t = s]

  • The state value function vπ(s)v_\pi(s) is the expected return starting from state ss and following policy π\pi.
  • How good it is to be in state ss (under policy π\pi)?

qπ(s,a)=Eπ[GtSt=s,At=a]q_\pi(s, a) = \mathbb{E}_{\pi}[G_t | S_t = s, A_t = a]

  • The expected return of taking action aa in state ss, taking action aa and then following policy π\pi.
  • qq: a quality of action aa in state ss (under policy π\pi).
FeatureState-Value Function (vπ(s)v_\pi(s))Action-Value Function (qπ(s,a)q_\pi(s, a))
Decision FlowFollows policy π\pi right from state ssCommits to action aa first, then follows policy π\pi
Intuitive Question"How good is it to be in this state?""How good is it to take this specific action in this state?"

Solving MDPs

Goal: Find optimal policy π\pi_* that maximizes the expected return.

  • Using Value Iteration or Policy Iteration.
  • Updating value functions and policies iteratively until convergence.
  • Evaluation: Compute the value function vπ(s)v_\pi(s) for a given policy π\pi.
  • Improvement: Update the policy π\pi to choose better actions based on the updated value function.
    • To converge to the optimal value function and policy v,πv^*, \pi^*

POMDPs

MDPs with hidden states.

S,A,O공간 (Spaces),P,R,Z함수 / 규칙 (Functions),γ상수 (Discount Factor)\langle \underbrace{\mathcal{S}, \mathcal{A}, \mathcal{O}}_{\text{공간 (Spaces)}}, \underbrace{\mathcal{P}, \mathcal{R}, \mathcal{Z}}_{\text{함수 / 규칙 (Functions)}}, \underbrace{\gamma}_{\text{상수 (Discount Factor)}} \rangle

  • SS: a finite set of states
  • A\mathcal{A}: a finite set of actions
  • O\mathcal{O}: a finite set of observations
    • e.g. driving in foggy weather.
  • P\mathcal{P}: a state transition matrix
  • R\mathcal{R}: a reward function
  • Z\mathcal{Z}: an observation function
    • Zs,oa=P[Ot+1=oSt+1=s,At=a]\mathcal{Z}_{s', o}^a = P[O_{t+1} = o | S_{t+1} = s', A_t = a]
    • an observation function specifying the probability of receiving observation oo given state ss' and action aa
    • After taking action aa and landing in state ss', how likely is the agent to observe oo?
  • γ\gamma: a discount factor
  • e.g.
    • Robot navigation with noisy/uncalibrated sensors.
    • Autonomous Driving with Sensor uncertainty due to bad weather conditions and unexpected events.

Finite Horizon MDPs

  • Finite Time Steps (TT): A sequential decision-making process restricted to a fixed, finite number of steps (TT) to maximize cumulative rewards.
  • Target Applications: Well-suited for problems with explicit deadlines or time-varying environment dynamics.
  • Decision Basis: Optimal decisions are made using current state (StS_t), available actions (AtA_t), transition probabilities (P\mathcal{P}), and immediate rewards (R\mathcal{R}).
  • Representative Example: A robot navigating a grid world with a limited step count or battery budget to reach a goal while avoiding obstacles.
  • Discount Factor (γ\gamma): Because the horizon TT is finite, the cumulative return cannot diverge to infinity, allowing the use of undiscounted formulations (γ=1\gamma = 1).
  • Time-Dependent (Non-Stationary) Policy:
    • Unlike infinite-horizon MDPs, the optimal action depends explicitly on the remaining time steps (TtT - t).
    • Policy Notation: πt(s)\pi_t(s) (indexed by time step tt).
    • Intuition: An agent may play conservatively early on, but take high-risk, high-reward actions right before the deadline.
DimensionFinite-Horizon MDPInfinite-Horizon MDP
Time Horizon (TT)T<T < \infty (Explicit terminal step)TT \to \infty (Perpetual / ongoing)
Policy NatureNon-Stationary (πt(s)\pi_t(s), changes over time)Stationary (π(s)\pi(s), time-invariant)
Discount Factor (γ\gamma)γ1\gamma \le 1 (γ=1\gamma = 1 is valid)Typically γ<1\gamma < 1 required for convergence
Objective FunctionmaxE[t=0TγtRt+1]\max \mathbb{E} \left[ \sum_{t=0}^{T} \gamma^t R_{t+1} \right]maxE[t=0γtRt+1]\max \mathbb{E} \left[ \sum_{t=0}^{\infty} \gamma^t R_{t+1} \right]

Limitations of MDPs

  • Markovian Assumption: Assumes future transitions depend solely on the current state StS_t, ignoring past historical trajectories and temporal dependencies that matter in real-world dynamics (e.g., momentum, acceleration).
    • State augmentation, frame stacking, RNN/Transformer, POMDP
  • Complete Knowledge Requirement: Assumes exact a priori knowledge of transition probabilities P\mathcal{P} and reward functions R\mathcal{R}, which are rarely accessible without sample-based learning in complex environments.
    • Model-free RL: Q-learning, SARSA, Policy Gradient
  • Finite State and Action Spaces: Restricted to discrete and countable sets, whereas real-world robotics and physical control tasks typically involve continuous states and actions.
    • Function approximation, Actor-Critic: DDPG, TD3, SAC, PPO
  • Curse of Dimensionality: Tabular value and policy storage scale exponentially as state dimensions grow (S×A|\mathcal{S}| \times |\mathcal{A}|), making high-dimensional environments (e.g., raw pixel inputs) computationally intractable.
    • Deep RL: neural approximation of VV, QQ, or π\pi
  • Partial Observability: Assumes full access to the true ground-truth state (Ot=StO_t = S_t), failing to account for real-world sensor noise, occlusions, and incomplete observations.
    • POMDP, belief-state estimation, recurrent policies