Skip to content
DeepForgeby svx
All problems
HardProbabilitypr-046

Absorbing Probability Two-State

Problem

Absorption in a two-state Markov chain where state 0 is absorbing.

From state 1 the chain moves to state 0 with probability p and otherwise stays in state 1. Starting from state 1, return [probability of eventual absorption, expected number of steps]: [1.0, 1.0 / p] when 0 < p < 1, [1.0, 1.0] when p >= 1, and [0.0, -1.0] when p <= 0.

Hint

Absorption follows a geometric distribution with success probability p.

Test cases

case 1
in: [0.5]
expected: [1,2]
case 2
in: [0.25]
expected: [1,4]
case 3
in: [1]
expected: [1,1]
case 4
in: [0]
expected: [0,-1]
case 5
in: [0.1]
expected: [1,10]
Starter codePython
def absorbing_probability_two_state(p):
    # Your code here
    pass

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