{"id":9039,"date":"2020-03-27T11:14:03","date_gmt":"2020-03-27T02:14:03","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=9039"},"modified":"2020-05-28T09:36:12","modified_gmt":"2020-05-28T00:36:12","slug":"%eb%aa%ac%ed%85%8c%ec%b9%b4%eb%a5%bc%eb%a1%9c-%eb%b0%a9%eb%b2%95montecarlo-method","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=9039","title":{"rendered":"\ubaac\ud14c\uce74\ub97c\ub85c \ubc29\ubc95(Montecarlo Method)"},"content":{"rendered":"<p>\ubaac\ud14c\uce74\ub97c\ub85c \ubc29\ubc95(Monte Carlo method)\uc740 \uc5b4\ub5a4 \ubb38\uc81c\uc5d0 \ub300\ud55c \ud574\ub97c \ubb34\uc218\ud788 \ub9ce\uc740 \uc2dc\ub3c4\ub97c \ud1b5\ud574 \uc5bb\uc5b4\uc9c4 \ud655\ub960\uc744 \uae30\ubc18\uc73c\ub85c \ud558\ub294 \uacc4\uc0b0\ubc95\uc785\ub2c8\ub2e4. \uc544\ub798\uc758 \uadf8\ub9bc\uc740 \uc704\ud0a4\ub514\ud53c\uc544\uc758 \ubaac\ud14c\uce74\ub97c\ub85c\uc5d0 \ub300\ud55c \uc18c\uac1c\uc5d0 \ub098\uc628 \uc774\ubbf8\uc9c0\ub85c\uc368 \uc6d0\uc8fc\uc728 \u03c0 \uac12\uc744 \uad6c\ud558\ub294 \uc608\uc785\ub2c8\ub2e4.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/2020\/03\/Pi_30K.gif\" alt=\"\" width=\"500\" height=\"500\" class=\"aligncenter size-full wp-image-9040\" \/><\/p>\n<p>\ub113\uc774\uac00 1\uc778 \uc815\uc0ac\uac01\ud615, \uc774 \uc815\uc0ac\uac01\ud615 \ub0b4\ubd80\uc5d0 \ubc18\uc9c0\ub984\uc774 1\uc778 \uc0ac\ubd84\uc6d0\uc774 \uc788\uc2b5\ub2c8\ub2e4. \uadf8\ub7ec\uba74 \uc0ac\ubd84\uc6d0\uc774 \ucc28\uc9c0\ud558\ub294 \ub113\uc774\ub294 \u03c0\/4\uac00 \ub420 \uac83\uc774\ub2e4. \uc774\uc81c 0 \uc774\uc0c1, 1 \uc774\ud558\uc778 x\uc640 y\uc758 \uac12\uc744 \ubb34\uc791\uc704\ub85c \ubf51\uc740 \ud6c4 x^2 + y^2 \u2264 1\uc758 \uc870\uac74\uc744 \ub9cc\uc871\ud560 \ud655\ub960\uc740 \uc0ac\ubd84\uc6d0\uc758 \ub113\uc774\uc640 \uac19\uc740 \u03c0\/4\uac00 \ub429\ub2c8\ub2e4.<\/p>\n<p>\uc704\uc758 \ub17c\ub9ac\ub97c \ucf54\ub4dc\ub85c \uc791\uc131\ud558\uc5ec \u03c0\ub97c \uad6c\ud558\uba74 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nimport random\r\n\r\nn = 1000000 # \ubc31\ub9cc\ubc88\uc758 \uc2dc\ub3c4\r\ncount = 0\r\n\r\nfor i in range(n):\r\n    # x, y\ub97c \ubb34\uc791\uc704\ub85c 0~1\uc0ac\uc774\uc758 \uac12\uc73c\ub85c \uacb0\uc815\r\n    x = random.uniform(0, 1)\r\n    y = random.uniform(0, 1)\r\n\r\n    # \uc0ac\ubd84\uc6d0 \ub0b4\ubd80\uc5d0 \ubc1c\uc0dd\ud558\ub294 \uacbd\uc6b0\uc218 \r\n    if (x**2 + y**2) <= 1: count += 1\r\n\r\n# \ubc31\ub9cc\ubc88\uc758 \uc2dc\ub3c4 \uc911 \uc0ac\ubd84\uc6d0 \ub0b4\ubd80\uc77c \uacbd\uc6b0\uc5d0 \ub300\ud55c \ud655\ub960\uc740 \uc0ac\ubd84\uc6d0\uc758 \ub113\uc774\uc774\ubbc0\ub85c \uc774\ub97c 4\ubc30 \uacf1\ud558\uc5ec \u03c0 \uacc4\uc0b0\r\nprint('phi', 4*count\/n)\r\n<\/pre>\n<p>\uc704\uc758 \ucf54\ub4dc \uc911 4*count\/n\uc740 \ub2e4\uc74c\uc758 \ube44\ub840\uc2dd\uc744 \ud1b5\ud574 \ub3c4\ucd9c\ub41c \uacb0\uacfc\uc785\ub2c8\ub2e4.<\/p>\n<p><center>\uc804\uccb4\ud655\ub960 : \uc0ac\ubd84\uc6d0 \ub0b4\ubd80\uc77c \uacbd\uc6b0\uc5d0 \ub300\ud55c \ud655\ub960 = \uc0ac\uac01\ud615\uc758 \ub113\uc774 : \uc0ac\ubd84\uc6d0\uc758 \ub113\uc774<\/center><\/p>\n<p>\uc704\uc758 \ube44\ub840\uc2dd\uc5d0 \uc218\uce58\uac12\uc744 \ub300\uc785\ud558\uba74 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<p><center>1 : count\/n = 1 : \u03c0\/4<\/center><\/p>\n<p>\ubaac\ud14c\uce74\ub97c\ub85c \ubc29\ubc95\uc744 \ud1b5\ud574 \uc2e4\uc81c\uc640 \uac00\uae4c\uc6b4 \ud574\ub97c \uc5bb\uae30 \uc704\ud574\uc11c\ub294 \ubc29\ub300\ud55c \ub2e8\uc21c \uacc4\uc0b0\uc744 \ub9e4\uc6b0 \ube60\ub974\uac8c \ucc98\ub9ac\ud560 \uc218 \uc788\ub294 \ucef4\ud4e8\ud130\uac00 \ud544\uc218\uc785\ub2c8\ub2e4. \uc774 \ubaac\ud14c\uce74\ub97c\ub85c \ubc29\ubc95\uc740 \ud575\ud3ed\ud0c4\uc774\ub098 \uc218\uc18c\ud3ed\ud0c4\uc758 \uac1c\ubc1c\uc5d0\uc11c \ud575\uc2ec\uc801\uc778 \uc5ed\ud65c\uc744 \ub2f4\ub2f9\ud588\ub2e4\uace0 \ud569\ub2c8\ub2e4. \uc81c \uacbd\uc6b0\ub3c4 \ud575\ud3ed\ud0c4 \uac1c\ubc1c\uc774 \ud544\uc694\ud574\uc11c... \uac00 \uc544\ub2cc \uac15\ud654\ud559\uc2b5(Reinforcement learning)\uc758 \ud55c \ubc29\ubc95\uc73c\ub85c \uc811\ud558\uac8c \ub418\uc5c8\uc2b5\ub2c8\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ubaac\ud14c\uce74\ub97c\ub85c \ubc29\ubc95(Monte Carlo method)\uc740 \uc5b4\ub5a4 \ubb38\uc81c\uc5d0 \ub300\ud55c \ud574\ub97c \ubb34\uc218\ud788 \ub9ce\uc740 \uc2dc\ub3c4\ub97c \ud1b5\ud574 \uc5bb\uc5b4\uc9c4 \ud655\ub960\uc744 \uae30\ubc18\uc73c\ub85c \ud558\ub294 \uacc4\uc0b0\ubc95\uc785\ub2c8\ub2e4. \uc544\ub798\uc758 \uadf8\ub9bc\uc740 \uc704\ud0a4\ub514\ud53c\uc544\uc758 \ubaac\ud14c\uce74\ub97c\ub85c\uc5d0 \ub300\ud55c \uc18c\uac1c\uc5d0 \ub098\uc628 \uc774\ubbf8\uc9c0\ub85c\uc368 \uc6d0\uc8fc\uc728 \u03c0 \uac12\uc744 \uad6c\ud558\ub294 \uc608\uc785\ub2c8\ub2e4. \ub113\uc774\uac00 1\uc778 \uc815\uc0ac\uac01\ud615, \uc774 \uc815\uc0ac\uac01\ud615 \ub0b4\ubd80\uc5d0 \ubc18\uc9c0\ub984\uc774 1\uc778 \uc0ac\ubd84\uc6d0\uc774 \uc788\uc2b5\ub2c8\ub2e4. \uadf8\ub7ec\uba74 \uc0ac\ubd84\uc6d0\uc774 \ucc28\uc9c0\ud558\ub294 \ub113\uc774\ub294 \u03c0\/4\uac00 \ub420 \uac83\uc774\ub2e4. \uc774\uc81c 0 \uc774\uc0c1, 1 \uc774\ud558\uc778 x\uc640 y\uc758 \uac12\uc744 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=9039\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;\ubaac\ud14c\uce74\ub97c\ub85c \ubc29\ubc95(Montecarlo Method)&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[131],"tags":[],"class_list":["post-9039","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/9039","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9039"}],"version-history":[{"count":13,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/9039\/revisions"}],"predecessor-version":[{"id":9046,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/9039\/revisions\/9046"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9039"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}