<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://nemenmanlab.org/~ilya/index.php?action=history&amp;feed=atom&amp;title=Physics_212%2C_2019%3A_Lecture_20</id>
	<title>Physics 212, 2019: Lecture 20 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://nemenmanlab.org/~ilya/index.php?action=history&amp;feed=atom&amp;title=Physics_212%2C_2019%3A_Lecture_20"/>
	<link rel="alternate" type="text/html" href="https://nemenmanlab.org/~ilya/index.php?title=Physics_212,_2019:_Lecture_20&amp;action=history"/>
	<updated>2026-04-27T01:29:16Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://nemenmanlab.org/~ilya/index.php?title=Physics_212,_2019:_Lecture_20&amp;diff=3326&amp;oldid=prev</id>
		<title>Ilya: Created page with &quot;{{PHYS212-2019}}  In today's lecture, we will introduce the first example of a Monte-Carlo simulation.  Follow the  Random Numbers notebook in thi...&quot;</title>
		<link rel="alternate" type="text/html" href="https://nemenmanlab.org/~ilya/index.php?title=Physics_212,_2019:_Lecture_20&amp;diff=3326&amp;oldid=prev"/>
		<updated>2019-04-03T13:05:02Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{PHYS212-2019}}  In today&amp;#039;s lecture, we will introduce the first example of a Monte-Carlo simulation.  Follow the &lt;a href=&quot;/~ilya/images/0/08/RandomNumbers.txt&quot; class=&quot;internal&quot; title=&quot;RandomNumbers.txt&quot;&gt; Random Numbers&lt;/a&gt; notebook in thi...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{PHYS212-2019}}&lt;br /&gt;
&lt;br /&gt;
In today's lecture, we will introduce the first example of a Monte-Carlo simulation.&lt;br /&gt;
&lt;br /&gt;
Follow the [[media:RandomNumbers.txt | Random Numbers]] notebook in this lecture.&lt;br /&gt;
&lt;br /&gt;
==Monte-Carlo area estimation==&lt;br /&gt;
We use random numbers to perform computations that are fundamentally random, and we will focus on those in the upcoming weeks. However, there are computations that are fundamentally deterministic, but may be easier to perform with random numbers. Suppose we want to calculate an integral under a curve &amp;lt;math&amp;gt;y=y(x)&amp;lt;/math&amp;gt;, with the limits &amp;lt;math&amp;gt;x\in [a,b]&amp;lt;/math&amp;gt;. We can, of course, do it analytically for some functions &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; or numerically by subdividing the interval of &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; into small segments &amp;lt;math&amp;gt;\Delta x&amp;lt;/math&amp;gt; and adding up the areas of all small rectangles, &amp;lt;math&amp;gt;y(x)\times \Delta x&amp;lt;/math&amp;gt;. An alternative way is as follows. Suppose we know that &amp;lt;math&amp;gt;y(x)&amp;lt;/math&amp;gt; is positive and smaller than &amp;lt;math&amp;gt;f_{\rm max}&amp;lt;/math&amp;gt;. Then the area under the curve can be written down as &amp;lt;math&amp;gt;(b-a)f_{\rm max}*\alpha&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; is the fraction of the square &amp;lt;math&amp;gt;b-a&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;f_{\rm max}&amp;lt;/math&amp;gt; that is actually under the curve. How do we estimate this fraction? Suppose I generate random points (dart throws), uniformly distributed over the square &amp;lt;math&amp;gt;b-a&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;f_{\rm max}&amp;lt;/math&amp;gt;. The fraction of those that end up under the curve (and it's easy to check which one does!) is an estimate of &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;. The provided script performs such calculation for an arbitrary &amp;lt;math&amp;gt;y=y(x)&amp;lt;/math&amp;gt;. This is called Monte-Carlo integration. Note that our implementation is incomplete -- we don't check if the function ever is below 0 or ever is above &amp;lt;math&amp;gt;f_{\rm max}&amp;lt;/math&amp;gt;, which a better implementation should do.&lt;br /&gt;
&lt;br /&gt;
==How precise are MC approaches?==&lt;br /&gt;
A problem, of course, is that such calculation is probabilistic -- every time we perform it, the results are different. But how different? We can verify, first of all, that our probabilistic estimate of the area converges to to true one, where true is known, e.g, when we integrate a function &amp;lt;math&amp;gt;x^2&amp;lt;/math&amp;gt;. We can also show the distribution of the estimates of the area when we perform the are estimate with &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; dart throws. We see that the larger &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is, the more concentrated the estimates are. To quantify this, we use the provided script to calculate the standard deviation of the estimates as a function of &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt;. We find that &amp;lt;math&amp;gt;\sigma^2 = A/N&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt; is some constant. The claim is that the general &amp;lt;math&amp;gt;1/N&amp;lt;/math&amp;gt; law holds true for essentially any function being integrated. It's only the constant that changes -- and we can verify this by integrating other functions.&lt;br /&gt;
&lt;br /&gt;
==Your work==&lt;br /&gt;
Verify that MC integration of different function still converges as &amp;lt;math&amp;gt;1/\sqrt{N}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Scripts==&lt;br /&gt;
[[media:RandomNumbers.txt | Random Numbers]] -- the Random Numbers notebook, which we will be exploring over multiple lectures.&lt;/div&gt;</summary>
		<author><name>Ilya</name></author>
		
	</entry>
</feed>