Skip to content
DeepForgeby svx
All problems
MediumProbabilitypr-129

Ehrenfest Stationary Distribution

Problem

Stationary distribution of the Ehrenfest chain with d balls, which is Binomial(d, 1/2):

pi[k] = C(d, k) / 2^d for k = 0..d.

Return the list of probabilities for k in increasing order.

Hint

Each ball independently ends up in the left box half the time at stationarity.

Test cases

case 1
in: [0]
expected: [1]
case 2
in: [1]
expected: [0.5,0.5]
case 3
in: [2]
expected: [0.25,0.5,0.25]
case 4
in: [4]
expected: [0.0625,0.25,0.375,0.25,0.0625]
Starter codePython
import math


def ehrenfest_stationary_distribution(d):
    # Your code here
    pass

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