{"id":46,"date":"2025-09-13T14:19:33","date_gmt":"2025-09-13T14:19:33","guid":{"rendered":"https:\/\/gsama.cc\/?p=46"},"modified":"2025-09-13T14:20:50","modified_gmt":"2025-09-13T14:20:50","slug":"guess-pi","status":"publish","type":"post","link":"https:\/\/gsama.cc\/?p=46","title":{"rendered":"can you guess the value \u03c0?"},"content":{"rendered":"\n<p>The word &#8220;guess&#8221; is loosely used here. <\/p>\n\n\n\n<p>Can we determine the value of \u03c0 by generating random number? <\/p>\n\n\n\n<p>As of 2024 humans have calculated 105 trillion digits of \u03c0. It feels like a stretch of imagination to think we could get even a fair approximation using only random numbers.<\/p>\n\n\n\n<p>But consider this: if we generate random points inside a square, and check how many fall inside an inscribed quarter circle, we can estimate \u03c0.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"952\" height=\"962\" src=\"https:\/\/gsama.cc\/wp-content\/uploads\/2025\/09\/Screenshot-2025-09-13-at-12.35.18-PM.png\" alt=\"\" class=\"wp-image-47\" style=\"width:300px;height:auto\" srcset=\"https:\/\/gsama.cc\/wp-content\/uploads\/2025\/09\/Screenshot-2025-09-13-at-12.35.18-PM.png 952w, https:\/\/gsama.cc\/wp-content\/uploads\/2025\/09\/Screenshot-2025-09-13-at-12.35.18-PM-297x300.png 297w, https:\/\/gsama.cc\/wp-content\/uploads\/2025\/09\/Screenshot-2025-09-13-at-12.35.18-PM-768x776.png 768w\" sizes=\"auto, (max-width: 952px) 100vw, 952px\" \/><\/figure>\n\n\n\n<p>Explanation: The probability of such randomly generated points to fall within the blue coloured quarter circle is <\/p>\n\n\n\n<div class=\"wp-block-katex-display-block katex-eq\" data-katex-display=\"true\"><pre>P(A) = \\frac{\\text{Area of Quarter Circle}}{\\text{Area of Square}}<\/pre><\/div>\n\n\n\n<div class=\"wp-block-katex-display-block katex-eq\" data-katex-display=\"true\"><pre>P(A) = \\frac{\\tfrac{1}{4}\\pi r^2}{r^2} = \\frac{\\pi}{4}<\/pre><\/div>\n\n\n\n<p>So if you have a large enough sample of points<\/p>\n\n\n\n<div class=\"wp-block-katex-display-block katex-eq\" data-katex-display=\"true\"><pre>\\pi = 4 \\cdot P(A)<\/pre><\/div>\n\n\n\n<p>or<\/p>\n\n\n\n<div class=\"wp-block-katex-display-block katex-eq\" data-katex-display=\"true\"><pre>\\pi = \\lim_{N_{\\text{total}} \\to \\infty} 4 \\cdot \\frac{N_{\\text{inside}}}{N_{\\text{total}}}<\/pre><\/div>\n\n\n\n<p>So next time you see \u03c0, remember \u2014 even randomness, given patience, knows its way home.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/gsama.cc\/custompages\/Pi_MonteCarlo.html\">Run Simulation<\/a><\/div>\n<\/div>\n\n\n\n<p class=\"has-small-font-size\">Note<br>\u2022 Using randomness to solve deterministic problems is called the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Monte_Carlo_method\">Monte Carlo method<\/a>.<br>\u2022 Demo created with AI tools \u2014 the code could use some polishing.<br>\u2022 The simulation speed is deliberately slowed down for effect. Left to the computer\u2019s clock speed, it would approximate \u03c0 to practical accuracy within seconds.<br>\u2022 Computers don\u2019t generate true randomness \u2014 only <a href=\"https:\/\/www.geeksforgeeks.org\/dsa\/pseudo-random-number-generator-prng\/\" data-type=\"link\" data-id=\"https:\/\/www.geeksforgeeks.org\/dsa\/pseudo-random-number-generator-prng\/\">pseudo-random numbers.<\/a><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The word &#8220;guess&#8221; is loosely used here. Can we determine the value of \u03c0 by generating random number? As of 2024 humans have calculated 105 trillion digits of \u03c0. It feels like a stretch of imagination to think we could get even a fair approximation using only random numbers. But consider this: if we generate [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[11,15],"class_list":["post-46","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-math-2","tag-pi"],"_links":{"self":[{"href":"https:\/\/gsama.cc\/index.php?rest_route=\/wp\/v2\/posts\/46","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gsama.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gsama.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gsama.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gsama.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=46"}],"version-history":[{"count":2,"href":"https:\/\/gsama.cc\/index.php?rest_route=\/wp\/v2\/posts\/46\/revisions"}],"predecessor-version":[{"id":49,"href":"https:\/\/gsama.cc\/index.php?rest_route=\/wp\/v2\/posts\/46\/revisions\/49"}],"wp:attachment":[{"href":"https:\/\/gsama.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=46"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gsama.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=46"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gsama.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}