Bernoulli.py
From Werner KRAUTH
[edit]
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).
[edit]
Python program
import random p = 0.7 count_a = 0 N_trial = 1000000 for iter in range(N_trial): Upsilon = random.uniform(0.0, 1.0) if Upsilon < p: count_a += 1 print(count_a / N_trial)