Skip to content
DeepForgeby svx
All problems
HardProbabilitypr-136

Stationary Birth-Death Probabilities

Problem

Stationary distribution of a birth-death chain on states 0..N. births[i] is the rate from state i to i + 1 and deaths[i] is the rate from state i + 1 down to i. Build pi[i + 1] = pi[i] * births[i] / deaths[i], then normalize. Return a list of probabilities, or [] when the lists are empty or mismatched or a death rate is nonpositive.

Hint

Detailed balance gives the ratio of neighboring stationary probabilities.

Test cases

case 1
in: [[0.5,0.5],[0.5,0.5]]
expected: [0.3333333333333333,0.3333333333333333,0.3333333333333333]
case 2
in: [[1,2],[2,1]]
expected: [0.4,0.2,0.4]
case 3
in: [[1,1,1],[1,1,1]]
expected: [0.25,0.25,0.25,0.25]
case 4
in: [[],[]]
expected: []
Starter codePython
def stationary_birth_death(births, deaths):
    # Your code here
    pass

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