[{"element_type":"image_url","content":"https://media.geeksforgeeks.org/wp-content/uploads/MonteCarlo.png","metadata":{"alt":"Random","caption":"Random points are generated only few of which lie outside the imaginary circle"}},{"element_type":"text","content":"\n        \u003cp\u003e\u003cstrong\u003eEstimate Pi with the\u003cspan\u003e\u0026nbsp;\u003c/span\u003e\u003cem\u003eMonte Carlo method\u003c/em\u003e\u003cspan\u003e\u0026nbsp;\u003c/span\u003eand a neotrinkey\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eThe power of randomness can be harnessed! Estimating the area of a circle by throwing darts at random gives you the means to estimate the value of Pi! I first learned about using the Monte Carlo back in the '80's and even used it in software development to estimate timing of events. You can use it with you NeoTrinkey to estimate the valueof Pi. You can find my github repository here:\u0026nbsp;\u003ca href=\"https://github.com/mrklingon/PieceOfPi/\" target=\"_blank\"\u003ehttps://github.com/mrklingon/PieceOfPi/\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003e\u003cem\u003eMonte Carlo methods are a broad class of computational algorithms that rely on repeated random sampling to obtain numerical results. One of the basic examples of getting started with the Monte Carlo algorithm is the estimation of Pi.\u003c/em\u003e\u003cspan\u003e\u0026nbsp;\u003c/span\u003e(\u003ca href=\"https://www.geeksforgeeks.org/estimating-value-pi-using-monte-carlo/\"\u003ehttps://www.geeksforgeeks.org/estimating-value-pi-using-monte-carlo/\u003c/a\u003e)\u003c/p\u003e\n\u003cp\u003eThis project iterates over a unit circle of radius one and \"throws\" darts at random from -1 to 1 x, and -1 to 1 y, then counts how many land\u003cspan\u003e\u0026nbsp;\u003c/span\u003e\u003cstrong\u003eIN\u003c/strong\u003e\u003cspan\u003e\u0026nbsp;\u003c/span\u003ethe circle. Pi is estimated by multiplying 4 *\u003cspan\u003e\u0026nbsp;\u003c/span\u003e\u003cstrong\u003e\"darts inside circle\"\u003c/strong\u003e/\u003cstrong\u003eall darts thrown\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eThe more iterations (darts) thrown, the closer you approach the value of Pi.\u003c/p\u003e\n\u003cp\u003eThe program runs continuously, pausing 5 seconds between runs. While the program is running/estimating, the neopixels flash random colors. When it finishes an estimate, the neopixel displays the answer by blinking the neopixels green for the value (three times for\u003cspan\u003e\u0026nbsp;\u003c/span\u003e\u003cem\u003ethree\u003c/em\u003e, one time for\u003cspan\u003e\u0026nbsp;\u003c/span\u003e\u003cstrong\u003eone\u003c/strong\u003e\u003cspan\u003e\u0026nbsp;\u003c/span\u003eand so on.). Zeroes are indicated by turning all pixels pink briefly. The pixels flash blue to indicate the decimal point.\u003c/p\u003e\n\u003cp\u003eIf the program is run inside a REPL like Mu, it will print out the results:\u003c/p\u003e\n\u003cpre class=\"notranslate\"\u003e\u003ccode\u003e I will estimate Pi.\nit is around : 3.14139\nI will estimate Pi.\nit is around : 3.13818\nI will estimate Pi.\nit is around : 3.13422\nI will estimate Pi.\nit is around : 3.1313 \n\u003c/code\u003e\u003c/pre\u003e\n\u003cp\u003eThe default value of Iterations is 100 - you can change that to higher or lower values.\u003c/p\u003e\n\u003cp\u003e\u003cspan style=\"text-decoration: underline;\"\u003e\u003cstrong\u003eFiles\u003c/strong\u003e\u003c/span\u003e\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003ca href=\"https://github.com/mrklingon/PieceOfPi/blob/main/findPi.py\" target=\"_blank\"\u003efindPi.py\u003c/a\u003e - copy to code.py to run\u003c/li\u003e\n\u003cli\u003e\n\u003ca href=\"https://github.com/mrklingon/PieceOfPi/blob/main/ncount.py\" target=\"_blank\"\u003encount.py\u003c/a\u003e - helper file, provides color definitions and blinknum() to blink the digit values.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eFor more about the Monte Carlo Method:\u003cspan\u003e\u0026nbsp;\u003c/span\u003e\u003ca href=\"https://en.wikipedia.org/wiki/Monte_Carlo_method\"\u003ehttps://en.wikipedia.org/wiki/Monte_Carlo_method\u003c/a\u003e\u003c/p\u003e\n      ","metadata":{}}]