ScratchData LogoScratchData
Back to colinomc's profile

Pi estimation

COcolinomc•Created March 16, 2014
Pi estimation
0
0
24 views
View on Scratch

Instructions

Estimates pi using the Monte Carlo method. Each iteration selects a new random point in the square. The point is colored purple if it is within the circle (the distance from 0,0 <= radius). The area of the square is: (2 * radius)^2 and the area of the circle is Pi * radius^2 The expected ratio of points in the circle to the total number of points is (Pi * radius^2) / (2 * radius)^2. The radius ^2 cancels out. The program calculates an actual ratio of points inside and outside the circle. So we get another formula: Pi / 4 = inCircle / totalPoints If you use algebra to solve for Pi, the equation becomes Pi = 4*inCircle / totalPoints. You might want to try turbo mode. The accuracy of the calculation is related to how random the numbers are.

Description

My dad wrote this.

Project Details

Project ID19361528
CreatedMarch 16, 2014
Last ModifiedMarch 17, 2014
SharedMarch 17, 2014
Visibilityvisible
CommentsAllowed