5.1.2 · HinglishReinforcement Learning Foundations

Markov Decision Processes (MDP)

2,776 words13 min readRead in English

5.1.2 · AI-ML › Reinforcement Learning Foundations

MDP kya hai?

Yeh components kyun?

  • States: Agent kahan ho sakta hai? (positions, configurations, observations)
  • Actions: Agent ke paas kya choices hain? (moves, controls, decisions)
  • Transitions: Jab main act karta hoon toh kya hota hai? (physics, rules, uncertainty)
  • Rewards: Kya achha/bura hai? (goals jo numbers ke roop mein encode hain)
  • Discount: Future rewards ki value kam hoti hai (impatience, uncertainty, mathematical convenience)

Value Function ko First Principles se Derive Karna

Goal: Ek policy dhundho (ek strategy jo states ko actions se map karti hai) jo total reward maximize kare.

Step 1: Total Return

State se shuru karke, agar hum policy follow karte hain, toh hume ek sequence milta hai:

Time se return saare future rewards ka sum hai:

Problem: Yeh sum infinite ho sakta hai aur near vs. far rewards mein distinguish nahi karta.

Step 2: Discounted Return

Discount kyun? Teen reasons:

  1. Uncertainty: Future kam certain hai, isliye worth less hai
  2. Impatience: Baad mein milne se pehle reward prefer karo (economic time-preference)
  3. Mathematical convergence: Infinite horizons ke liye finite sums ensure karta hai

Discounted return:

Yeh kyun kaam karta hai: Agar aur rewards se bounded hain, toh: Geometric series converge ho jaati hai!

Step 3: State-Value Function

State-value function woh expected return hai jo state se shuru karke aur policy follow karke milta hai:

Expectation kyun? Transitions stochastic hain (), isliye hum saare possible futures ka average lete hain.

Expand karte hain:

Key insight: khud se ek return hai, isliye .

Step 4: Bellman Equation Derivation

Policy ke under, hum deterministically action lete hain (ya stochastic policies ke liye se sample karte hain). Deterministic ke liye:

Ise tod ke samjhte hain:

  1. Hum state mein hain, policy kehti hai action lo
  2. Environment randomly next state choose karta hai probability ke saath
  3. Hume immediate reward milta hai
  4. Phir naye state se hume discounted future value milti hai

Step 5: Action-Value Function (Q-function)

Kabhi kabhi hum jaanna chahte hain: "State mein action lena kitna achha hai (aur phir follow karna)?"

Action-value function:

Derivation:

se relationship:

Optimal Policy aur Bellman Optimality

Goal: Optimal policy dhundho jo saare states ke liye value maximize kare:

Optimal value functions define karo:

Bellman Optimality Equation Derive Karna

Agar best possible value hai, toh:

Kyun? Optimal policy ko woh action choose karna chahiye jiska Q-value sabse zyada ho.

Q-function expansion substitute karte hain:

Q-function ke liye:

Optimal policy extraction: Jab ek baar humein ya mil jaaye:

Worked Examples

Common Mistakes aur Fixes

Memory Aids

Recall Feynman Explain-to-a-12-Year-Old

Socho tum ek board game khel rahe ho. Har turn pe, tum kisi square pe ho (woh state hai). Tum ek move choose karte ho (woh tumhara action hai). Game mein kuch randomness hai—shayad tum dice roll karte ho dekhne ke liye ki tum kahan land karoge (woh transition probability hai). Jab tum land karte ho, tumhe points milte hain ya lose hote hain (woh reward hai).

Ab, Markov property kehti hai: sirf tumhara current square matter karta hai tumhara next move decide karne aur tum kahan land karoge yeh decide karne ke liye. Tumhe har square yaad rakhne ki zaroorat nahi jo tumne pehle visit kiya—bas dekho tum abhi kahan ho.

Tumhari policy tumhari strategy hai: "Jab main square X pe hoon, main move Y choose karunga." Ek square ki value hai: "Agar main yahan se shuru karun aur smartly kheluun, toh total mujhe kitne points milenge?" Discount factor aise kehna hai ki "Mujhe woh points zyada care karta hai jo mujhe jald milenge rather than dur future ke points."

Bellman equation sirf iske liye math hai: "Mere current square ki value = abhi mujhe milne wale points + jahan main next land karunga uski (discounted) value."

Best strategy dhundna matlab hai: har square ke liye, woh move choose karo jo sabse zyada total points tak le jaata hai. Wahi optimal policy hai!

Connections

  • 5.1.01-Reinforcement-Learning-Problem-Formulation - MDPs RL problem ko formalize karte hain
  • 5.1.03-Policy-and-Value-Functions - Policies aur values ka deep dive
  • 5.1.04-Bellman-Equations - Bellman equations ka detailed treatment
  • 5.2.01-Dynamic-Programming-inRL - MDPs ko DP methods se solve karna
  • 5.3.01-Monte-Carlo-Methods - aur ka model-free estimation
  • 5.3.02-Temporal-Difference-Learning - TD learning online updates ke liye Bellman equation use karta hai
  • 5.4.01-Q-Learning - Q-values ke liye Bellman optimality equation use karta hai
  • Markov-Chains - MDPs, Markov chains ko actions aur rewards add karke extend karte hain
  • Dynamic-Programming - MDP solution methods DP algorithms hain

#flashcards/ai-ml

MDP mein Markov Property kya hai? :: Next state ki probability sirf current state aur action pe depend karti hai, history pe nahi:

MDP ke paanch components kya hain?
States (S), Actions (A), transition Probability (P), Rewards (R), aur discount factor (gamma)
Discount factor kya hai aur yeh kyun zaroori hai?
[0,1) mein ek value jo future rewards ko immediate rewards se kam valuable banati hai. Mathematical convergence ke liye zaroori hai (finite sums ensure karta hai), future ke baare mein uncertainty model karta hai, aur control karta hai ki agent kitna farsighted hai.
State-value function kya hai?
State se shuru hokar aur policy follow karke milne wala expected return (cumulative discounted reward):
Action-value function kya hai?
State se shuru hokar, action lekar, phir policy follow karke milne wala expected return:
ke liye Bellman Expectation Equation batao
— value equals immediate reward plus discounted future value
ke liye Bellman Optimality Equation batao
— optimal value equals actions ke maximum of expected reward + discounted optimal future
se optimal policy kaise extract karte hain?
— har state mein sabse zyada Q-value wala action choose karo
aur mein kya relationship hai?
— state ki value equals us action ki Q-value jo policy us state mein leti hai
MDP mein policy kya hai?
States se actions ka ek mapping (deterministic) ya ek probability distribution (stochastic) jo agent ka behavior define karta hai
Agar aur tum terminal reward 100 se 3 steps door ek state mein ho, toh undiscounted contribution kya hai?
Continuing tasks mein kyun use nahi kar sakte?
Kyunki rewards ka infinite sum diverge ho jaata (infinite value), jisse problem mathematically intractable ho jaati hai jab tak saare rewards zero na hon
ke liye effective planning horizon kya hai?
Approximately steps — itni door future mein agent effectively consider karta hai

Sach ya Jhooth: Markov property ka matlab hai policy historical information use nahi kar sakti :: Jhooth. Policy history use kar sakti hai agar state mein encode ki gayi ho. Markov property environment dynamics pe apply hoti hai, policy design pe nahi.

MDP ke context mein model-based aur model-free RL mein kya fark hai?
Model-based ko aur (MDP model) pata hota hai aur woh planning use kar sakta hai. Model-free ko yeh nahi pata aur use experience se seekhna padta hai.

Concept Map

defined as tuple

includes

includes

includes

includes

includes

relies on

mapped by policy

generates

ensures convergence of

expected value gives

recursive form

Markov Decision Process

S A P R gamma

States S

Actions A

Transition P(s prime given s, a)

Reward R

Discount gamma

Markov Property Memoryless

Policy pi

Discounted Return G_t

State-Value V pi

Bellman Equation