Top to random simul.py

From Werner KRAUTH

Jump to: navigation, search

Context

This page is part of my 2024 Beg Rohu Lectures on "The second Markov chain revolution" at the Summer School "Concepts and Methods of Statistical Physics" (3 - 15 June 2024).

Python program

import random
NCards = 3
data = {}
for iter1 in range(1000000):
    L= [k for k in range(NCards)]
    for iter2 in range(10):
        a = L.pop(0)
        L.insert(random.randint(0, len(L)), a)
    L = tuple(L)
    data[L] = data.get(L, 0) + 1
for k in data:
    print(k, data[k])
Personal tools