All problems
Three State Chain Stationary Solve
Problem
Find the stationary distribution pi of a three-state chain by solving the linear system pi (P - I) = 0 with sum(pi) = 1. Use Gaussian elimination on the augmented system built from the transposed balance equations.
Given a 3x3 transition matrix, return [pi0, pi1, pi2].
Hint
Replace the redundant balance equation with the normalization constraint.
Test cases
case 1
in: [[[0.5,0.5,0],[0.25,0.5,0.25],[0,0.5,0.5]]]
expected: [0.25,0.5,0.25]
case 2
in: [[[0,1,0],[0,0,1],[1,0,0]]]
expected: [0.3333333333333333,0.3333333333333333,0.3333333333333333]
case 3
in: [[[0.2,0.8,0],[0.1,0.1,0.8],[0.3,0.3,0.4]]]
expected: [0.2112676056338028,0.3380281690140845,0.4507042253521127]
Starter codePython
def three_state_chain_stationary_solve(transition):
# Your code here
pass3 test cases · run your code against them in the editor