All problems
Two State Chain One Step
Problem
For the two-state chain with transition matrix [[1 - a, a], [b, 1 - b]], one step maps the distribution p to [p0 (1 - a) + p1 b, p0 a + p1 (1 - b)].
Given the distribution [p0, p1], a, and b, return the next distribution.
Hint
Multiply the row vector by the transition matrix.
Test cases
case 1
in: [[1,0],0.2,0.3]
expected: [0.8,0.2]
case 2
in: [[0.5,0.5],0.1,0.4]
expected: [0.65,0.35]
case 3
in: [[0,1],0.5,0.5]
expected: [0.5,0.5]
Starter codePython
def two_state_chain_one_step(p, a, b):
# Your code here
pass3 test cases · run your code against them in the editor