All problems
Stationary Distribution Two-State
Problem
Stationary distribution of a two-state Markov chain.
State 0 goes to state 1 with probability p and state 1 goes to state 0 with probability q. Return [pi_0, pi_1] = [q / (p + q), p / (p + q)]. If p + q is 0 return [1.0, 0.0].
Hint
Solve pi_0 * p = pi_1 * q together with pi_0 + pi_1 = 1.
Test cases
case 1
in: [0.1,0.2]
expected: [0.6666666666666666,0.3333333333333333]
case 2
in: [0.5,0.5]
expected: [0.5,0.5]
case 3
in: [0,1]
expected: [1,0]
case 4
in: [1,0]
expected: [0,1]
case 5
in: [0,0]
expected: [1,0]
Starter codePython
def stationary_distribution_2state(p, q):
# Your code here
pass5 test cases · run your code against them in the editor