Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-209

Regime Switching Probability

Problem

Evolve a two-state Markov chain. States are 0 and 1 with persistence probabilities p00 and p11; start with probability 1 on start and step the distribution `steps` times, then return [prob_state0, prob_state1].

Transition rows are [p00, 1-p00] and [1-p11, p11].

Hint

The chain converges to its stationary distribution as steps grow.

Test cases

case 1
in: [0.8,0.7,0,1]
expected: [0.8,0.19999999999999996]
case 2
in: [0.8,0.7,0,2]
expected: [0.7000000000000002,0.29999999999999993]
case 3
in: [0.9,0.6,1,1]
expected: [0.4,0.6]
case 4
in: [0.5,0.5,0,3]
expected: [0.5,0.5]
Starter codePython
def regime_probability_after_steps(p00, p11, start, steps):
    # Your code here
    pass

4 test cases · run your code against them in the editor