All problems
Detailed Balance Check Two State
Problem
A two-state chain satisfies detailed balance for pi when pi0 P01 equals pi1 P10; check within a tolerance.
Given pi0, pi1, P01, P10, and the tolerance, return True when detailed balance holds.
Hint
Compare the probability flux in both directions.
Test cases
case 1
in: [0.5,0.5,0.2,0.2,1e-9]
expected: true
case 2
in: [0.5,0.5,0.3,0.1,1e-9]
expected: false
case 3
in: [0.75,0.25,0.2,0.6,1e-9]
expected: true
Starter codePython
def detailed_balance_check_two_state(pi0, pi1, p01, p10, tol):
# Your code here
pass3 test cases · run your code against them in the editor