All problems
Markov Entropy Rate (2-State)
Problem
For a two-state Markov chain with transition probabilities p01 (0 -> 1) and p10 (1 -> 0), return the entropy rate in bits:
pi0 = p10 / (p01 + p10), pi1 = p01 / (p01 + p10) R = pi0 * H(p01) + pi1 * H(p10)
where H is the binary entropy function in bits.
Hint
The stationary distribution weights each state's transition entropy.
Test cases
case 1
in: [0.5,0.5]
expected: 1
case 2
in: [0,1]
expected: 0
case 3
in: [0.1,0.2]
expected: 0.5533064273553082
case 4
in: [0.5,0.25]
expected: 0.8741854163060885
Starter codePython
import math
def markov_rate_2state(p01, p10):
# Your code here
pass4 test cases · run your code against them in the editor