<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Daniel Gur on Medium]]></title>
        <description><![CDATA[Stories by Daniel Gur on Medium]]></description>
        <link>https://medium.com/@danielgur?source=rss-34266efcb7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*tsbYGSuwK9hjJIDQ.png</url>
            <title>Stories by Daniel Gur on Medium</title>
            <link>https://medium.com/@danielgur?source=rss-34266efcb7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 22:11:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@danielgur/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Approximation for Pi using the Monte Carlo Method]]></title>
            <link>https://medium.com/@danielgur/approximation-for-pi-using-the-monte-carlo-method-279205a3cf9?source=rss-34266efcb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/279205a3cf9</guid>
            <dc:creator><![CDATA[Daniel Gur]]></dc:creator>
            <pubDate>Sun, 17 Nov 2013 04:56:46 GMT</pubDate>
            <atom:updated>2013-11-17T04:56:46.850Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*8tOc5At9hU2E7t5SwqtzpA.png" /></figure><p>A disk has an area of πr^2. We will use a disk with radius 1. Random coordinates (x,y) are then chosen with x,y ∈ [0,1]. These coordinates will either be inside or outside the disk. We then count the random points that fall inside the unit disk, and then divide it by the number of random coordinates generated. That number will give us an estimate for π/4. We can simply multiply that solution by 4 to get our estimate for π.</p><p>Below is the Matlab code:</p><pre>iters = 100;<br>count = 0;<br>for i=1:iters <br>  x = rand; <br>  y = rand; <br>  fromCenter = sqrt(x^2 + y^2); <br>  if(fromCenter &lt;= 1) <br>    count = count + 1; <br>  end<br>end<br>approxForPi = 4*(count/iters)</pre><p>Note: increase <em>iters</em> for a better approximation.</p><p>An image has been attached to explain visually how this solution is achieved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*LS5yDwbeWr8VOH-pv33VQQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=279205a3cf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>