<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article  PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article"><front><journal-meta><journal-id journal-id-type="publisher-id">AM</journal-id><journal-title-group><journal-title>Applied Mathematics</journal-title></journal-title-group><issn pub-type="epub">2152-7385</issn><publisher><publisher-name>Scientific Research Publishing</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="doi">10.4236/am.2017.83022</article-id><article-id pub-id-type="publisher-id">AM-74541</article-id><article-categories><subj-group subj-group-type="heading"><subject>Articles</subject></subj-group><subj-group subj-group-type="Discipline-v2"><subject>Physics&amp;Mathematics</subject></subj-group></article-categories><title-group><article-title>
 
 
  Buffon’s Needle Algorithm to Estimate π
 
</article-title></title-group><contrib-group><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Chi-Ok</surname><given-names>Hwang</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref><xref ref-type="corresp" rid="cor1"><sup>*</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Yeongwon</surname><given-names>Kim</given-names></name><xref ref-type="aff" rid="aff2"><sup>2</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Cheolgi</surname><given-names>Im</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Sunggeun</surname><given-names>Lee</given-names></name><xref ref-type="aff" rid="aff3"><sup>3</sup></xref></contrib></contrib-group><aff id="aff2"><addr-line>Concentration of Electrical Engineering and Computer Science, GIST College, Gwangju, Korea</addr-line></aff><aff id="aff3"><addr-line>Concentration of Physics, GIST College, Gwangju, Korea</addr-line></aff><aff id="aff1"><addr-line>Division of Liberal Arts and Sciences, GIST College, Gwangju, Korea</addr-line></aff><author-notes><corresp id="cor1">* E-mail:<email>chwang@gist.ac.kr(CH)</email>;</corresp></author-notes><pub-date pub-type="epub"><day>03</day><month>03</month><year>2017</year></pub-date><volume>08</volume><issue>03</issue><fpage>275</fpage><lpage>279</lpage><history><date date-type="received"><day>13,</day>	<month>December</month>	<year>2016</year></date><date date-type="rev-recd"><day>28,</day>	<month>February</month>	<year>2017</year>	</date><date date-type="accepted"><day>3,</day>	<month>March</month>	<year>2017</year></date></history><permissions><copyright-statement>&#169; Copyright  2014 by authors and Scientific Research Publishing Inc. </copyright-statement><copyright-year>2014</copyright-year><license><license-p>This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/</license-p></license></permissions><abstract><p>
 
 
  Buffon’s needle experiment was originally devised to get the value of π. With the advent of computers, Buffon’s needle algorithm has been used pedagogically as an example of Monte Carlo methods in introduction classes, and there are many Buffon’s needle algorithm implementations available on the internet. However, for the calculation of π, the exact value of π is used in the programs for Buffon’s needle angle sampling, and hence the example is not demonstrated correctly. This brief note presents a random angle sampling algorithm for the Buffon’s needle. We then compare the Buffon’s needle and Hit-and-Miss integration algorithms using Monte Carlo laboriousness comparison, and find that the Hit-and-Miss algorithm is superior.
 
</p></abstract><kwd-group><kwd>Buffon’s Needle</kwd><kwd> Monte Carlo</kwd><kwd> Angle Sampling</kwd></kwd-group></article-meta></front><body><sec id="s1"><title>1. Introduction</title><p>Buffon’s needle experiment [<xref ref-type="bibr" rid="scirp.74541-ref1">1</xref>] was originally used to provide π . Throwing a needle (see <xref ref-type="fig" rid="fig1">Figure 1</xref>) onto a flat plane with equally-spaced parallel lines, the probability that the needle touches the parallel line provides an estimate for π is</p><p>P = ∫ 0 π l 2 sin θ d θ π d / 2 (1)</p><p>and so</p><p>π = 2 l P a (2)</p><p>where P is the probability, l the length of the needle and a the spacing with l &lt; a .</p><p>Here, we should note that the Buffon’s needle problem becomes an integration problem (see <xref ref-type="fig" rid="fig2">Figure 2</xref>) so the probability is just the ratio of areas.</p><p>Many variants of the original Buffon’s needle experiment [<xref ref-type="bibr" rid="scirp.74541-ref2">2</xref>] [<xref ref-type="bibr" rid="scirp.74541-ref3">3</xref>] [<xref ref-type="bibr" rid="scirp.74541-ref4">4</xref>] [<xref ref-type="bibr" rid="scirp.74541-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.74541-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.74541-ref7">7</xref>] have been developed. Kendall and Moran [<xref ref-type="bibr" rid="scirp.74541-ref2">2</xref>] and Diaconis [<xref ref-type="bibr" rid="scirp.74541-ref3">3</xref>] examined several aspects of the problem for a long needle ( l &gt; a ) and Siniksaran [<xref ref-type="bibr" rid="scirp.74541-ref7">7</xref>] used Mathematics to review various statistical aspects of the experiment.</p><p>With the advent of computers, Buffon’s needle has been pedagogically used as an example in Monte Carlo method introductory classes and many websites pro- vide Buffon’s needle algorithm implementations. However, in these programs, the value of π is used for the random sampling of the needle angular direction. Thus π is used to obtain the value of π itself.</p><p>This note presents a sampling algorithm for the random direction of the needle that avoids using π within the algorithm. We then compare the Buffon’s needle and the Hit-and-Miss integration algorithms using the common Monte Carlo algorithm comparison method, the time consumption (laboriousness) [<xref ref-type="bibr" rid="scirp.74541-ref8">8</xref>] .</p></sec><sec id="s2"><title>2. Buffon’s Needle Algorithm</title><p>For random direction sampling of the needle, we use a square enclosing a tightly fitted circle (see <xref ref-type="fig" rid="fig3">Figure 3</xref>).</p><p>Since the directions of the random points inside the circle are uniform, we obtain uniform needle random directions.</p></sec><sec id="s3"><title>3. Comparison with the Hit-and-Miss Algorithm</title><p>The Hit-and-Miss integration algorithm can also provide the value of π . Using one quadrant of the circle circumscribed by a square (see <xref ref-type="fig" rid="fig4">Figure 4</xref>), we can obtain π = 4 h , where, h is the probability of hitting the shaded area, when we generate a pair of random numbers to sample a random point inside of the square.</p><p>We use the common Monte Carlo algorithm comparison, time consumption (laboriousness): [<xref ref-type="bibr" rid="scirp.74541-ref8">8</xref>] t D _ ξ where t is the CPU time expended in calculating a single estimate and D _ ξ estimate variance. <xref ref-type="fig" rid="fig5">Figure 5</xref> shows the log-log plot of the number of Monte Carlo steps v.s. the errors of the two algorithms, and <xref ref-type="table" rid="table1">Table 1</xref> compare the two algorithms. The Hit-and-Miss algorithm is superior to the Buffon’s needle algorithm for calculation of #Math_28#, which seems reasonable given the Buffon’s needle algorithm requires more numerical operations for a Monte Carlo step. Of course, we can improve Buffon’s algorithm performance using a tighter non-constant proposed probability distribution for the acceptance-rejec- tion sampling method. Using quasi-Monte Carlo random numbers [<xref ref-type="bibr" rid="scirp.74541-ref9">9</xref>] for the angle sampling will also improve the convergence.</p></sec><sec id="s4"><title>4. Conclusion</title><p>Buffon’s needle algorithm has been pedagogically used as an introduction to</p><table-wrap id="table1" ><label><xref ref-type="table" rid="table1">Table 1</xref></label><caption><title> Time consumption of Buffon’s needle and Hit-and-Miss algorithm. Variances were obtained from 100 independent runs and the number of random walks per run was 10 7 </title></caption><table><tbody><thead><tr><th align="center" valign="middle" ><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-7403449x37.png" xlink:type="simple"/></inline-formula></th><th align="center" valign="middle" >CPU time per run (s)</th><th align="center" valign="middle" >Variance (<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-7403449x38.png" xlink:type="simple"/></inline-formula>)</th><th align="center" valign="middle" >Time consumption (<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-7403449x39.png" xlink:type="simple"/></inline-formula>)</th></tr></thead><tr><td align="center" valign="middle" >Buffon’s needle</td><td align="center" valign="middle" >15.9</td><td align="center" valign="middle" >5.97</td><td align="center" valign="middle" >9.49</td></tr><tr><td align="center" valign="middle" ><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-7403449x40.png" xlink:type="simple"/></inline-formula></td><td align="center" valign="middle" >13.0</td><td align="center" valign="middle" >2.51</td><td align="center" valign="middle" >3.26</td></tr></tbody></table></table-wrap><p>Monte Carlo methods. However, π is used for needle angle sampling inside the original algorithm. This note presents a method for the needle angle sampling without using π and make the Buffon’s needle algorithm a Monte Carlo method to estimate π . We compared the Buffon’s needle and Hit-and-Miss integration algorithms and found that the Buffon’s needle algorithm is not superior to the Hit-and-Miss integration algorithm.</p></sec><sec id="s5"><title>Acknowledgements</title><p>This research was supported by the Basic Science Research Program through the National Research Foundation of Korea (NRF) funded by the Ministry of Education, Science and Technology (2012R1A1A2003025). Also, later this work was supported by the GIST Research Institute (GRI) in 2017. In addition, this research was a collaborative research project, supercomputing infrastructure service and application, supported by the Korea institute of science and technology information.</p></sec><sec id="s6"><title>Cite this paper</title><p>Hwang, C.-O., Kim, Y., Im, C. and Lee, S. (2017) Buffon’s Needle Algorithm to Estimate π. Applied Ma- thematics, 8, 275-279. https://doi.org/10.4236/am.2017.83022</p></sec></body><back><ref-list><title>References</title><ref id="scirp.74541-ref1"><label>1</label><mixed-citation publication-type="other" xlink:type="simple">Buffon, G. (1777) Essai da’rithme’tique morale. Histoire Naturelle, Générale, et Particuliére, Supplément, 4, 685.</mixed-citation></ref><ref id="scirp.74541-ref2"><label>2</label><mixed-citation publication-type="other" xlink:type="simple">Morton, R.A. (1966) The Expected Number and Angle of Intersections between Random Curves in a Plane. Journal of Applied Probability, 3, 559-562. https://doi.org/10.1017/S0021900200114342</mixed-citation></ref><ref id="scirp.74541-ref3"><label>3</label><mixed-citation publication-type="journal" xlink:type="simple"><name name-style="western"><surname>Diaconis</surname><given-names> P. </given-names></name>,<etal>et al</etal>. (<year>1976</year>)<article-title>Buffon’s Problem with a Long Needle</article-title><source> Journal of Applied Probability</source><volume> 13</volume>,<fpage> 614</fpage>-<lpage>618</lpage>.<pub-id pub-id-type="doi"></pub-id></mixed-citation></ref><ref id="scirp.74541-ref4"><label>4</label><mixed-citation publication-type="other" xlink:type="simple">Periman, M.D. and Wichura, M.J. (1975) Sharpening Buffon’s Needle. Amer. Stat, 29, 157.</mixed-citation></ref><ref id="scirp.74541-ref5"><label>5</label><mixed-citation publication-type="other" xlink:type="simple">Solomon, H. (1987) Geometric Probability. SIAM, Philadelphia.</mixed-citation></ref><ref id="scirp.74541-ref6"><label>6</label><mixed-citation publication-type="other" xlink:type="simple">Wood, G.R. and Robertson, J.M. (1998) Information in Buffon Experiments. Journal of Statistical Planning and Inferences, 66, 415-421.</mixed-citation></ref><ref id="scirp.74541-ref7"><label>7</label><mixed-citation publication-type="other" xlink:type="simple">Siniksaran, E. (2008) Throwing Buffon’s Needle with Mathematica. The Mathematical Journal, 11, 71.</mixed-citation></ref><ref id="scirp.74541-ref8"><label>8</label><mixed-citation publication-type="other" xlink:type="simple">Sobol, I.M. (1994) A Primer for the Monte Carlo Method. CRC Press, Washington DC.</mixed-citation></ref><ref id="scirp.74541-ref9"><label>9</label><mixed-citation publication-type="other" xlink:type="simple">Lemieux, C. (2009) Monte Carlo and Quasi-Monte Carlo Sampling. Springer-Verlag, New York.</mixed-citation></ref></ref-list></back></article>