<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.lptms.universite-paris-saclay.fr//wiki-cours/index.php?action=history&amp;feed=atom&amp;title=SMAC_Introduction_to_Monte_Carlo</id>
	<title>SMAC Introduction to Monte Carlo - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://www.lptms.universite-paris-saclay.fr//wiki-cours/index.php?action=history&amp;feed=atom&amp;title=SMAC_Introduction_to_Monte_Carlo"/>
	<link rel="alternate" type="text/html" href="http://www.lptms.universite-paris-saclay.fr//wiki-cours/index.php?title=SMAC_Introduction_to_Monte_Carlo&amp;action=history"/>
	<updated>2026-08-06T10:33:59Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>http://www.lptms.universite-paris-saclay.fr//wiki-cours/index.php?title=SMAC_Introduction_to_Monte_Carlo&amp;diff=883&amp;oldid=prev</id>
		<title>Wiki-cours: /* Direct sampling or the children&#039;s game */</title>
		<link rel="alternate" type="text/html" href="http://www.lptms.universite-paris-saclay.fr//wiki-cours/index.php?title=SMAC_Introduction_to_Monte_Carlo&amp;diff=883&amp;oldid=prev"/>
		<updated>2018-06-05T14:27:42Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Direct sampling or the children&amp;#039;s game&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:27, 5 June 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l25&quot;&gt;Line 25:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 25:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Monte Carlo is an integration algorithm.The above direct-sampling algorithms treats a probability distribution (uniform distribution of pebbles within the square), and an observable, the &amp;quot;hitting variable&amp;quot; (one within the unit circle, zero outside):&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Monte Carlo is an integration algorithm.The above direct-sampling algorithms treats a probability distribution (uniform distribution of pebbles within the square), and an observable, the &amp;quot;hitting variable&amp;quot; (one within the unit circle, zero outside):&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;:&lt;/ins&gt;&amp;lt;math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;\frac{n_\text{hits} } {N} \sim \frac{ \int_{-1}^{1} dx \int_{-1}^{1} dy \pi(x,y) O(x,y) } {&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;\frac{n_\text{hits} } {N} \sim \frac{ \int_{-1}^{1} dx \int_{-1}^{1} dy \pi(x,y) O(x,y) } {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;\int_{-1}^{1} dx \int_{-1}^{1} dy \pi(x,y) }&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;\int_{-1}^{1} dx \int_{-1}^{1} dy \pi(x,y) }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Wiki-cours</name></author>
	</entry>
	<entry>
		<id>http://www.lptms.universite-paris-saclay.fr//wiki-cours/index.php?title=SMAC_Introduction_to_Monte_Carlo&amp;diff=882&amp;oldid=prev</id>
		<title>Wiki-cours: /* Monte Carlo algorithms */</title>
		<link rel="alternate" type="text/html" href="http://www.lptms.universite-paris-saclay.fr//wiki-cours/index.php?title=SMAC_Introduction_to_Monte_Carlo&amp;diff=882&amp;oldid=prev"/>
		<updated>2018-06-05T14:26:34Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Monte Carlo algorithms&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:26, 5 June 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l23&quot;&gt;Line 23:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 23:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[image:direct_pi_color.png width=&amp;quot;554&amp;quot; height=&amp;quot;456&amp;quot; align=&amp;quot;center&amp;quot; caption=&amp;quot;Output of the direct-sampling program with &amp;quot;hits&amp;quot; in red and &amp;quot;non-hits&amp;quot; in blue.&amp;quot;]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[image:direct_pi_color.png width=&amp;quot;554&amp;quot; height=&amp;quot;456&amp;quot; align=&amp;quot;center&amp;quot; caption=&amp;quot;Output of the direct-sampling program with &amp;quot;hits&amp;quot; in red and &amp;quot;non-hits&amp;quot; in blue.&amp;quot;]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Monte Carlo is an integration algorithm.The above direct-sampling algorithms treats a probability distribution (uniform distribution of pebbles within the square), and an observable, the &amp;quot;hitting variable&amp;quot; (one within the unit circle, zero outside):&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Monte Carlo is an integration algorithm.The above direct-sampling algorithms treats a probability distribution (uniform distribution of pebbles within the square), and an observable, the &amp;quot;hitting variable&amp;quot; (one within the unit circle, zero outside):&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[&lt;/del&gt;math&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;&lt;/ins&gt;math&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;\frac{n_\text{hits} } {N} \sim \frac{ \int_{-1}^{1} dx \int_{-1}^{1} dy \pi(x,y) O(x,y) } {&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;\frac{n_\text{hits} } {N} \sim \frac{ \int_{-1}^{1} dx \int_{-1}^{1} dy \pi(x,y) O(x,y) } {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;\int_{-1}^{1} dx \int_{-1}^{1} dy \pi(x,y) }&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;\int_{-1}^{1} dx \int_{-1}^{1} dy \pi(x,y) }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[&lt;/del&gt;math&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/&lt;/ins&gt;math&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Comments===  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Comments===  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Wiki-cours</name></author>
	</entry>
	<entry>
		<id>http://www.lptms.universite-paris-saclay.fr//wiki-cours/index.php?title=SMAC_Introduction_to_Monte_Carlo&amp;diff=881&amp;oldid=prev</id>
		<title>Wiki-cours: Created page with &quot;=Monte Carlo algorithms=   ==Direct sampling or the children&#039;s game==   image:IN_children.jpg align=&quot;center&quot; caption=&quot;Children playing at the Monte Carlo beach&quot;   The game...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.lptms.universite-paris-saclay.fr//wiki-cours/index.php?title=SMAC_Introduction_to_Monte_Carlo&amp;diff=881&amp;oldid=prev"/>
		<updated>2018-06-05T14:24:24Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;=Monte Carlo algorithms=   ==Direct sampling or the children&amp;#039;s game==   &lt;a href=&quot;/wiki-cours/index.php?title=File:IN_children.jpg_align%3D%22center%22_caption%3D%22Children_playing_at_the_Monte_Carlo_beach%22&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;File:IN children.jpg align=&amp;quot;center&amp;quot; caption=&amp;quot;Children playing at the Monte Carlo beach&amp;quot; (page does not exist)&quot;&gt;image:IN_children.jpg align=&amp;quot;center&amp;quot; caption=&amp;quot;Children playing at the Monte Carlo beach&amp;quot;&lt;/a&gt;   The game...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Monte Carlo algorithms= &lt;br /&gt;
&lt;br /&gt;
==Direct sampling or the children&amp;#039;s game== &lt;br /&gt;
&lt;br /&gt;
[[image:IN_children.jpg align=&amp;quot;center&amp;quot; caption=&amp;quot;Children playing at the Monte Carlo beach&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The game takes place on the beach of Monte Carlo. The[[@http://commons.wikimedia.org/wiki/File:Pebbleswithquarzite.jpg| pebbles]] are samples of the uniform probability distribution in the square. They are obtained directly. It is for this reason that the algorithm is called &amp;quot;direct-sampling&amp;quot; Monte Carlo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;py&amp;quot;&amp;gt;&lt;br /&gt;
from random import uniform&lt;br /&gt;
def direct_pi(N):&lt;br /&gt;
    n_hits = 0&lt;br /&gt;
    for i in range(N):&lt;br /&gt;
        x, y = uniform(-1.0, 1.0), uniform(-1.0, 1.0)&lt;br /&gt;
        if x ** 2 + y ** 2 &amp;lt; 1.0:&lt;br /&gt;
            n_hits += 1&lt;br /&gt;
    return n_hits&lt;br /&gt;
n_trials = 10000&lt;br /&gt;
for attempt in range(10):&lt;br /&gt;
    print attempt, 4 * direct_pi(n_trials) / float(n_trials)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:direct_pi_color.png width=&amp;quot;554&amp;quot; height=&amp;quot;456&amp;quot; align=&amp;quot;center&amp;quot; caption=&amp;quot;Output of the direct-sampling program with &amp;quot;hits&amp;quot; in red and &amp;quot;non-hits&amp;quot; in blue.&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Monte Carlo is an integration algorithm.The above direct-sampling algorithms treats a probability distribution (uniform distribution of pebbles within the square), and an observable, the &amp;quot;hitting variable&amp;quot; (one within the unit circle, zero outside):&lt;br /&gt;
[[math]]&lt;br /&gt;
\frac{n_\text{hits} } {N} \sim \frac{ \int_{-1}^{1} dx \int_{-1}^{1} dy \pi(x,y) O(x,y) } {&lt;br /&gt;
\int_{-1}^{1} dx \int_{-1}^{1} dy \pi(x,y) }&lt;br /&gt;
[[math]]&lt;br /&gt;
&lt;br /&gt;
===Comments=== &lt;br /&gt;
&lt;br /&gt;
# Direct-sampling algorithms exist only for a handful of physically interesting models. They are very useful&lt;br /&gt;
# The existence of a uniform (pseudo) random number generator is assumed. The setup of good random number generators is a mature branch of mathematics.&lt;br /&gt;
&lt;br /&gt;
==Markov Chain Monte Carlo: the adult&amp;#039;s game== &lt;br /&gt;
&lt;br /&gt;
[[image:fig.1.02.jpg align=&amp;quot;center&amp;quot; caption=&amp;quot;Adults playing on the Monte Carlo heliport&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
The game takes place at Monte Carlo heliport. The helipad is a too large for direct sampling and a Markov chain strategy should be adopted. An adult stands at the last pebble position and draws the new pebble inside a square of side //delta//. An important rejection problem has to be fixed every time the new pebble jumps outside the helipad. The solution we adopt allows to uniformly cover the large square with pebbles.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;py&amp;quot;&amp;gt;&lt;br /&gt;
from random import uniform&lt;br /&gt;
def markov_pi(delta, N):&lt;br /&gt;
    x, y = 1.0, 1.0&lt;br /&gt;
    N_hits = 0&lt;br /&gt;
    for i in range(N):&lt;br /&gt;
        del_x, del_y = uniform(-delta, delta), uniform(-delta, delta)&lt;br /&gt;
        if abs(x + del_x) &amp;lt; 1.0 and abs( y + del_y ) &amp;lt; 1.0:&lt;br /&gt;
            x, y = x + del_x, y + del_y&lt;br /&gt;
        if x**2 + y**2 &amp;lt; 1.0:&lt;br /&gt;
            N_hits += 1.0&lt;br /&gt;
     return N_hits&lt;br /&gt;
&lt;br /&gt;
n_trials = 10000&lt;br /&gt;
for k in range(10):&lt;br /&gt;
    print 4 * markov_pi(0.3, n_trials) / float(n_trials)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Comments=== &lt;br /&gt;
# In Markov-chain sampling algorithms the initial condition must be allowed, not necessary typical&lt;br /&gt;
# Here adults start their promenade from the &amp;quot;club house&amp;quot; located in (x,y) = (1,1).&lt;br /&gt;
# The algorithm is correct for all step sizes //delta//, but best performance are obtained for moderate //delta//.&lt;br /&gt;
# **Rule of thumb:** acceptance ratio of Markov chain should be close to 1/2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Detailed and global balance== &lt;br /&gt;
For simplicity we discuss a simplified and discrete 3x3 pebble game. The pebble walks on a 3x3-chessboard without periodic boundary conditions.&lt;br /&gt;
&lt;br /&gt;
[[image:PRank1.png width=&amp;quot;300&amp;quot; height=&amp;quot;300&amp;quot;]] [[image:PRank2.png width=&amp;quot;300&amp;quot; height=&amp;quot;300&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We design a Markov chain algorithm, so that each site is visited with the same probability:&lt;br /&gt;
[[math]]&lt;br /&gt;
\pi(1) =&lt;br /&gt;
\pi(2)=&lt;br /&gt;
\pi(3)=&lt;br /&gt;
\pi(4)=&lt;br /&gt;
\pi(5)=&lt;br /&gt;
\pi(6)=&lt;br /&gt;
\pi(7)=&lt;br /&gt;
\pi(8)=&lt;br /&gt;
\pi(9)= \frac{1}{9}&lt;br /&gt;
[[math]]&lt;br /&gt;
Here a pebble throw consists in moving from a site to each of its neighbors with probability 1/4.&lt;br /&gt;
Suppose we are on site //a//=9, at one time. We can only move to //b//=8 or //c//=6, or simply remain at //a//. This gives&lt;br /&gt;
&lt;br /&gt;
[[math]]&lt;br /&gt;
p_{a \to a} + p_{a \to b} + p_{a \to c} = 1&lt;br /&gt;
[[math]]&lt;br /&gt;
&lt;br /&gt;
On the same time, to get to //a//, we either come from //a//, or from //b// or from //c//.&lt;br /&gt;
&lt;br /&gt;
[[math]]&lt;br /&gt;
\pi(a)p(a \to a) + \pi(b) p(b\to a) + \pi(c) p(c \to a) = \pi(a)&lt;br /&gt;
[[math]]&lt;br /&gt;
&lt;br /&gt;
This yields the &amp;#039;&amp;#039;&amp;#039;global balance condition&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[math]]&lt;br /&gt;
\pi(b) p(b\to a) + \pi(c) p(c \to a) = \pi(a) p(a\to b) + \pi(a) p(a \to c)&lt;br /&gt;
[[math]]&lt;br /&gt;
&lt;br /&gt;
A more restrictive condition is called &amp;#039;&amp;#039;&amp;#039;detailed balance condition&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
[[math]]&lt;br /&gt;
\pi(b) p(b\to a) = \pi(a) p(a\to b), \text{etc.}&lt;br /&gt;
[[math]]&lt;br /&gt;
&lt;br /&gt;
Below a Python implementation for the 3x3 pebble game. With positions 1,2,...,9, the four neighbors of site 1 are (2,4,1,1). This ensures that the pebble moves with probability 1/4 to sites 2 and 4, and remains on site 1 with probability 1/2. We start the simulation from site 9.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;py&amp;quot;&amp;gt;&lt;br /&gt;
import random, pylab&lt;br /&gt;
neighbor = {1 : [2, 4, 1, 1], 2 : [3, 5, 1, 2], 3 : [3, 6, 2, 3],&lt;br /&gt;
            4 : [5, 7, 4, 1], 5 : [6, 8, 4, 2], 6 : [6, 9, 5, 3],&lt;br /&gt;
            7 : [8, 7, 7, 4], 8 : [9, 8, 7, 5], 9 : [9, 9, 8, 6]}&lt;br /&gt;
all_pos = []&lt;br /&gt;
N_iter = 100&lt;br /&gt;
for iter1 in range(10000):&lt;br /&gt;
    pos = 9&lt;br /&gt;
    for iter in range(N_iter):&lt;br /&gt;
        pos = neighbor[ pos][ random.randint(0, 3)]&lt;br /&gt;
    all_pos.append(pos)&lt;br /&gt;
pylab.figure(1)&lt;br /&gt;
pylab.hist(all_pos,bins=9,range=(0.5,9.5),normed=True)&lt;br /&gt;
pylab.title(&amp;#039;3x3 pebble game, starting at 9, after &amp;#039;+str(N_iter)+&amp;#039; steps&amp;#039;)&lt;br /&gt;
pylab.savefig(&amp;#039;histo_3x3_&amp;#039;+str(N_iter)+&amp;#039;_steps.png&amp;#039;)&lt;br /&gt;
pylab.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is output of the above Python program for 5, 10, 100 steps&lt;br /&gt;
&lt;br /&gt;
[[image:histo_3x3_5_steps.png width=&amp;quot;280&amp;quot; height=&amp;quot;200&amp;quot;]] [[image:histo_3x3_10_steps.png width=&amp;quot;280&amp;quot; height=&amp;quot;200&amp;quot;]][[image:histo_3x3_100_steps.png width=&amp;quot;280&amp;quot; height=&amp;quot;200&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
==Inhomogeneous 3x3 pebble game (Metropolis algorithm)== &lt;br /&gt;
For a general probability distribution&lt;br /&gt;
[[math]]&lt;br /&gt;
\pi(1),\pi(2), \dots, \pi(9),&lt;br /&gt;
[[math]]&lt;br /&gt;
we can use the celebrated Metropolis algorithm&lt;br /&gt;
[[math]]&lt;br /&gt;
p(a \to b) = \min(1, \pi(b)/\pi(a) )&lt;br /&gt;
[[math]]&lt;br /&gt;
That we illustrate in a Python program for the inhomogeneous 3x3 pebble game.&lt;br /&gt;
&lt;br /&gt;
[[image:histo_3x3_inhomogeneous_1000000_steps.png align=&amp;quot;center&amp;quot; caption=&amp;quot;Histogram obtained by Metropolis versus the exact probabilities (red dots)&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comments=== &lt;br /&gt;
# Markov-chain Monte Carlo algorithms are a very general tool for integration.&lt;br /&gt;
# They access the relevant information in the infinite-time limit , but one can do better.&lt;br /&gt;
# The dynamics of the Markov-chain Monte Carlo algorithm is not always physically relevant.&lt;br /&gt;
# Many Markov-chain Monte Carlo algorithms satisfy detailed balance, but the necessary condition is global balance.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# We were deeply inspired by the first chapter of [[http://www.lps.ens.fr/~krauth/index.php/SMAC|SMAC]]  pp 1-9; 15-22&lt;br /&gt;
# here you can find the original paper by [[http://bayes.wustl.edu/Manual/EquationOfState.pdf|N. Metropolis, A.W. Rosenbluth, M.N. Rosenbluth, A.H. Teller et E. Teller (1953)]]&lt;/div&gt;</summary>
		<author><name>Wiki-cours</name></author>
	</entry>
</feed>