Pi-Thon banner

Pi-Thon

4 devlogs
6h 31m 27s

A Python simulation of Buffon’s Needle problem to estimate the value of Pi using the Monte Carlo method.

Including both a python script and a web app.

Note- Image Credits :Me

This project uses AI

Gemini was used for the code in making the code more interactive and some inputs to keep the user engaged.

Demo Repository

Loading README...

vaibhaav3

Completed the web app, additional debugging was done, the UI was improved and the appearance was enhanced, also the the balloons were added for a cool effect in the end overall I am pretty happy with the results.

Just go to the left sidebar and input any valid number and then click Fry the Needles to view the results, you shall observe that the value of the pi moves closer to the actual value as you increase the number of fries.

Happy Frying :)

Attachment
Attachment
Attachment
Attachment
0
vaibhaav3

Made an interactive simulation for estimating the value of Pi, Added funny comments and outputs that I hope will make maths less scary. Hope I cooked up something good enough.

Also got started on my code for my web app.

Attachment
Attachment
0
vaibhaav3

Finally I completed the full coding part and did the debugging so I have started writing another code to make it more interactive and fun as I realised the first was was too boring and was a bit tooo mathematical and has been made flavortown themed and for this part I have replaced the needles with French Fries, Yummm!!
So this is what I have done for now, but plan to make It more fun and enjoyable to use in the coming days.

Otherwise I believe that the century old mathematics holds still true and the value of Pi can just be estimated by using a bit of probability or to sound more fancy Stochastic Property. You shall notice that the value of Pi and is Approximations comes much closer to the actual value when the total number of fries or the needles dropped are increased.

Attachment
Attachment
0
vaibhaav3

Built a base Monte Carlo simulation of Buffon’s Needle problem.
I Decided to go with a simplified model where L=1.0 and D=2.0. This collapses the probability formula P= 2L/πD down to P= 1/π
Wrote the simulate_buffon function using random.uniform to handle the needle’s center point and its angle. Spent some time debugging the crossing condition: x <= (L/2) * abs(math.sin(theta)).

Attachment
Attachment
Attachment
0