All problems
Markov Chain One-Step
Problem
One-step update of a Markov chain distribution.
Given a probability vector state and a transition matrix where matrix[i][j] = P(i -> j), return the row vector with entries sum_i state[i] * matrix[i][j].
Hint
Multiply the row vector by the transition matrix.
Test cases
case 1
in: [[1,0],[[0.5,0.5],[0.2,0.8]]]
expected: [0.5,0.5]
case 2
in: [[0,1],[[0.5,0.5],[0.2,0.8]]]
expected: [0.2,0.8]
case 3
in: [[0.3,0.7],[[1,0],[0.4,0.6]]]
expected: [0.58,0.42]
case 4
in: [[0.5,0.5],[[1,0],[1,0]]]
expected: [1,0]
Starter codePython
def markov_one_step(state, matrix):
# Your code here
pass4 test cases · run your code against them in the editor