CMP338 Simulation and Modeling

Simulation and ModelingUnit 49 min read

Markov Chains: States, Transitions & Applications

Unit 4 of Simulation and Modeling explores Markov Chains—discrete-time stochastic processes where future states depend only on the current state (memoryless property). This note covers definitions, transition matrices, steady-state probabilities, and real-world applications in queuing, finance, and AI, with visual exam

TAKEAWAYS:

  • Markov Chains model systems where future states depend only on the current state (Markov Property), ignoring history.
  • A transition matrix encodes probabilities of moving between states, with rows summing to 1.
  • Steady-state probabilities (π) solve and model long-term behavior (e.g., equilibrium traffic flow).
  • Applications include page-rank algorithms (Google), weather forecasting, and financial risk modeling.
  • Discrete-time chains (e.g., daily stock prices) vs. continuous-time (e.g., radioactive decay) differ in state evolution.
  • Exam focus: Derive transition matrices, compute steady states, and interpret real-world traces (e.g., customer loyalty in eSewa).

1. What Are Markov Chains?

A Markov Chain is a stochastic (random) process that moves between states over discrete time steps, where the next state depends only on the current state. This is called the Markov Property: Key Idea: The future is independent of the past given the present.

Visual: State Space as a Graph

graph TD
    A["State 1"] -->|"0.3"| B["State 2"]
    A -->|"0.7"| C["State 3"]
    B -->|"0.5"| A
    B -->|"0.5"| C
    C -->|"0.2"| A
    C -->|"0.8"| B

Caption: A 3-state Markov Chain with transition probabilities. Bold arrows show a possible path: .


2. Definitions and Notation

  • State Space (S): Set of all possible states (e.g., ).
  • Transition Probability: .
  • Transition Matrix (P): Square matrix where is the probability of moving from state to . Example: Rows sum to 1 (probability conservation).

Real Picture: Markov Chain in eSewa


3. How Markov Chains Work: Worked Example

Scenario: A customer using Khalti for payments has 3 states:

  1. Active User (uses Khalti weekly),
  2. Inactive User (no transactions for a month),
  3. Churned (deleted app).

Given transition matrix: Question: If 100 users start as Active, what’s the distribution after 2 weeks?

Step-by-Step Trace

  1. Initial State Vector: (all users active).
  2. After 1 Week ():
    • 60 users stay active, 30 become inactive, 10 churn.
  3. After 2 Weeks ():
    • 42 active, 39 inactive, 19 churned.

Visual: State Evolution

graph LR
    A["Week 0: 100 Active"] --> B["Week 1: 60A, 30I, 10C"]
    B --> C["Week 2: 42A, 39I, 19C"]

Caption: User distribution over 2 weeks. Churn grows due to high transition from Inactive to Churned.


4. Steady-State Probabilities

In the long run, the state distribution stabilizes to , where: For Khalti Example: Solve : Solution: Interpretation:

  • 28.57% of users stay active long-term.
  • 35.71% churn or become inactive permanently.

Real World: Google’s PageRank

Google’s PageRank algorithm uses Markov Chains to rank web pages. Each page is a state, and links are transitions. The steady-state vector gives the "importance" of each page.

  • Example: If Page A links to Page B (probability 0.8), and Page B links back to A (probability 0.3), the transition matrix encodes these probabilities.
  • Result: Pages with more "incoming transitions" (links) have higher .

5. Types of Markov Chains

Type Definition Example Transition Matrix Property
Discrete-Time States change at fixed time intervals. Daily stock prices. defines jumps at .
Continuous-Time States change at random times. Radioactive decay. Governed by exponential distributions.
Irreducible All states communicate (reachable). Khalti user states (no isolated states). for some .
Recurrent Return to a state almost surely. Weather cycles (rain → sun → rain). .
Transient May leave a state forever. Failed login attempts. .

Visual: Irreducible vs. Reducible Chain

graph TD
    A["Irreducible"] --> B["All states reachable"]
    C["Reducible"] --> D["States 1 & 2 communicate"]
    D --> E["State 3 isolated"]

Caption: Irreducible chains (left) allow transitions between all states, while reducible chains (right) have isolated states (e.g., churned users in Khalti).


6. Applications in Nepal and Globally

In Nepal

  1. Traffic Flow Modeling (Kathmandu)

    • States: "Moving," "Idle," "Red Light."
    • Transitions: Probability of stopping at a red light or getting stuck in traffic.
    • Use Case: Optimize signal timings using steady-state probabilities to reduce congestion.
  2. NEPSE Stock Market

    • States: "Bull Market," "Bear Market," "Stable."
    • Transitions: Historical data shows 60% chance of staying in the same state, 30% chance of switching.
    • Use Case: Predict long-term trends for investment strategies.
  3. Pathao Driver Availability

    • States: "Available," "On Trip," "Offline."
    • Transitions: Drivers go offline after 3 trips (80% probability).
    • Use Case: Estimate driver supply to meet demand spikes.

Global Examples

  1. YouTube Recommendation System

    • States: "Watching Video," "Paused," "Closed."
    • Transitions: Probability of clicking a suggested video (0.4) vs. closing the app (0.1).
    • Use Case: Maximize watch time using Markov rewards.
  2. Netflix Binge-Watching

    • States: "Watching Episode," "Paused," "Switched Show."
    • Transitions: 70% chance of watching the next episode if engaged.
    • Use Case: Personalize recommendations based on steady-state engagement.
  3. Bank Loan Default Prediction (Global Banks)

    • States: "Good Credit," "Risky," "Default."
    • Transitions: Historical data shows 5% of "Risky" customers default monthly.
    • Use Case: Adjust interest rates dynamically (e.g., higher rates for "Risky" states).

7. Advantages and Limitations

Advantages Limitations
Models systems with memoryless dependencies. Assumes future depends only on current state (may not hold in reality).
Steady-state analysis predicts long-term behavior. Requires accurate transition probabilities (hard to estimate).
Used in optimization (e.g., traffic lights, queues). Computationally intensive for large state spaces.
Interpretable for decision-making. Sensitive to initial conditions in transient phases.

8. Worked Example: NTC Call Center

Scenario: NTC’s call center has 3 states:

  1. Idle (no calls),
  2. Handling Call,
  3. Queueing.

Transition matrix: Question: What’s the steady-state probability of the system being Idle?

Solution Steps

  1. Set up equations for :
  2. Solve with .
  3. Result: .
    • 25% chance the call center is idle long-term.

Real Picture: Call Center Dashboard


Exam Tip

  1. Derive Transition Matrices:

    • Given a scenario (e.g., Khalti users), always write the matrix first.
    • Example: If 30% of active users churn monthly, set .
  2. Steady-State Questions:

    • Solve systematically:
      1. Write equations for each state.
      2. Use to eliminate one variable.
      3. Solve the remaining system.
    • Shortcut: For 2-state chains, use .
  3. Interpretation:

    • Steady-state: "In the long run, what fraction of time is the system in state X?"
    • Transient: "What’s the probability of being in state X after 3 steps?"
  4. Common Pitfalls:

    • Forgetting rows sum to 1 in .
    • Misapplying the Markov Property (e.g., assuming future depends on past states).
    • Always check if the chain is irreducible (no isolated states).
  5. Graphical Help:

    • Draw the state diagram before writing equations.
    • Label arrows with probabilities to avoid errors.

Summary Checklist

  • Can you write the transition matrix for a given scenario?
  • Do you know how to compute steady-state probabilities?
  • Can you distinguish between discrete-time and continuous-time chains?
  • Do you recognize Markov Chains in real-world systems (e.g., Google PageRank)?
  • Can you interpret steady-state results (e.g., "25% idle time" for NTC)?

Based on the PU BE Computer (PU) syllabus for Simulation and Modeling (CMP338), unit 4.

Discussion

Loading…