Randomly Throwing Things to Estimate Pi (Summer 2023)
Did you know you can estimate by randomly throwing darts at a circle inscribed in a square? Press the play button below to run a simulation.
Here's how to make a simplified version of the simulation. Enter the following in different lines of the input bar below.
1) poly1=Polygon((-1,-1),(1,-1),4)
2) x^2+y^2=1
3) n=Slider(1,1000,1)
4) l1=Sequence(RandomPointIn(poly1),k,1,n)
5) l2=Sequence(If((x(Element(l1,k)))^(2)+(y(Element(l1,k)))^(2)>1,0,1),k,1,n)
6) a=Sum(l2)
7) PiEstimate=((4 a)/(n))
Once your simulation is working, you can:
Edit the colors of the square and points (choose your favorites).
Edit the slider, to see even more points. Does this impact the estimate of ?
You can even randomly throw frozen hot dogs at parallel lines and get an estimate of . Press the play button below to run a simulation.