Stopping circle.py
From Werner KRAUTH
(Difference between revisions)
| Revision as of 20:12, 12 June 2024 Werner (Talk | contribs) ← Previous diff |
Revision as of 22:12, 12 June 2024 Werner (Talk | contribs) Next diff → |
||
| Line 1: | Line 1: | ||
| + | ==Context== | ||
| + | This page is part of my [[BegRohu_Lectures_2024|2024 Beg Rohu Lectures]] on "The second Markov chain revolution" at the [https://www.ipht.fr/Meetings/BegRohu2024/index.html Summer School] "Concepts and Methods of Statistical Physics" (3 - 15 June 2024). | ||
| + | |||
| + | ==Python program== | ||
| + | |||
| import random | import random | ||
| N_trials = 100000 | N_trials = 100000 | ||
Revision as of 22:12, 12 June 2024
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
N_trials = 100000
N = 6
data = [0] * N
for iter in range(N_trials):
NotVisited = set([k for k in range(N)])
x = 0
if random.uniform(0.0, 1.0) < 1.0 / N:
data[x] += 1.0 / N_trials
else:
NotVisited = set([k for k in range(N)])
NotVisited.discard(x)
while len(NotVisited) > 0:
sigma = random.choice([-1, 1])
x = (x + sigma) % N
NotVisited.discard(x)
data[x] += 1.0 / N_trials
print('stopping samples')
for k in range(N):
print('site = ', k,' probability = ', data[k])
site = 0 probability = 0.1673 site = 1 probability = 0.1671 site = 2 probability = 0.1645 site = 3 probability = 0.1657 site = 4 probability = 0.1656 site = 5 probability = 0.1696
