Skip to content

jfaraudo/MonteCarlo-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monte Carlo example and python programming

This is one of the classical and simplest example of a Monte Carlo simulation, the calculation of the area of a circle and the Pi number using Monte Carlo method. The only assumption is that the area of a square is known.

We provide here two different algorithms for the same calculation: simple direct Monte Carlo and Markov chain Monte Carlo. The implementations are provided in pyhton3 scripts and Google Colab notebooks.

The convergence folder provides an example of the performance of the algorithms as we increase the number of attemps.

The algorithms are an implementation of Algorithm 1.1 and 1.2 from the book by W Krauth "Statistical Mechanics Algorithms and Computations" Oxford University press (see book site here )

For other similar implementations see for example , Wikipedia MonteCarlo article and many others such this video.

The implementation provided here shows a plot illustrating the number of succesful attemps that launched over a circle for pedagogical purposes.

We also provide a simple code that plots a circle inside a unit square (used for the graphical part of the code)

About

Simple example to illustrate Monte Carlo simulation by calculating number Pi

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors