Markov Chain Stationary Distribution

medium
Unit 18 · Online Learning0/2 to milestone

A Markov chain with row-stochastic transition matrix PP settles into a stationary distribution π\pi with πP=π\pi P = \pi and ∑π=1\sum \pi = 1.

Implement:

  • stationary(P): solve the linear system exactly (replace one equation of (P⊤−I)π=0(P^\top - I)\pi = 0 with the normalisation constraint)
  • power_iteration(P, iters=1000): start from the uniform distribution and repeatedly apply π←πP\pi \leftarrow \pi P
#probability#markov-chains#linear-algebra2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Markov Chain Stationary Distribution · TechGradify