Bernoulli two pebbles.py
From Werner KRAUTH
(Difference between revisions)
Revision as of 05:31, 6 June 2024 Werner (Talk | contribs) ← Previous diff |
Revision as of 15:03, 6 June 2024 Werner (Talk | contribs) Next diff → |
||
Line 1: | Line 1: | ||
+ | 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). | ||
+ | |||
import random | import random | ||
p = 0.7 | p = 0.7 |
Revision as of 15:03, 6 June 2024
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).
import random p = 0.7 phat = 0.4 count_a = 0 N_trial = 1000000 for iter in range(N_trial): Upsilon_1 = random.uniform(0.0, 1.0) if Upsilon_1 < phat: count_a += 1 else: Upsilon_2 = random.uniform(phat, 1.0) if Upsilon_2 < p: count_a += 1 print(count_a / N_trial)