Bernoulli poisson.py

From Werner KRAUTH

(Difference between revisions)
Jump to: navigation, search
Revision as of 12:51, 6 June 2024
Werner (Talk | contribs)

← Previous diff
Current revision
Werner (Talk | contribs)

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, math import random, math
p = 0.7 p = 0.7

Current revision

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, math
p = 0.7
lam = - math.log(1.0 - p)
N_trial = 1000000
count_a = 0
for iter in range(N_trial):
    t = -math.log(random.uniform(0., 1.0)) / lam
    if t < 1.0: count_a += 1
print(count_a / N_trial)
Personal tools