|Home | Games | Awards | About | Learn | Blog | Press Kit | Contact|
By: Matthew Doucette
A "sequel" to Random Pi, I thought why not try the same idea -- of estimating Pi with random numbers landing in and out of the unit-sphere -- with uniformly distributed numbers.
Similar but not the same as Random Pi, the idea is to chose evenly distributed numbers within the unit square (-1.0..1.0,-1.0..1.0) and measure the percentage of points lying inside the unit sphere. Using the area of a circule formula -- area = pi * radius^2 -- you can deduce the inside:total ratio multiplied by 4 is Pi.
This is known as the Monte Carlo method, although that method is usually choosing random numbers, not evenly distributed numbers.
From the output above you can see at first, only 4 numbers are chosen, at the edges of the unit square (-1.0..1.0,-1.0..1.0):
Then, the step is divided by two, breaking down the unit square into smaller pieces, so 9 numbers are chosen (total = 13 = 4+ 9):
. . .
Then, the step is divided by two again, so 25 numbers are chosen (total = 38 = 4 + 9 + 25):
. . . . .
And so on...
The algorithm repeats the same points each phase. What I could have done is coded it to to be offsetted so that each phase it is sampling just as many points -- perhaps with one row and one column less -- without repeats.
After 4 days, 13 hours, 32 minutes, and 49.9 seconds, 93,825,025,791,339 samples were taken, which estimate pi to be 3.1415922449233500 which is off by 0.000000408666442, accurate to 99.9999591334%.
Each estimate takes approximately 4 times longer than the previous one, so the calculation times grows exponentially for each successive step. Based on the last two estimates, it is 3.94110053 times longer:
Assuming this value, we can estimate future values:
If I left it running, I would not likely be alive to see the 6th extra result. And it was about 100,000..200,000 years ago that we evolved into humans, so by the 12th extra result, a lot could happen to us on evolutionary time frames.
P.S. The unit square is actually from (0.0..1.0,0.0..1.0) not (-1.0..1.0,-1.0..1.0).
Check out our other prototype work if you wish.
That is all.
About the Author: I am Matthew Doucette of Xona Games, an award-winning indie game studio that I founded with my twin brother. We make intensified arcade-style retro games. Our business, our games, our technology, and we as competitive gamers have won prestigious awards and received worldwide press. Our business has won $180,000 in contests. Our games have ranked from #1 in Canada to #1 in Japan, have become #1 best sellers in multiple countries, have won game contests, and have held 3 of the top 5 rated spots in Japan of all Xbox LIVE indie games. Our game engines have been awarded for technical excellence. And we, the developers, have placed #1 in competitive gaming competitions -- relating to the games we make. Read about our story, our awards, our games, and view our blog.
Home | Games | Awards | About | Learn | Blog | Press Kit | Contact
Xona Games, Xona.com, Xonatech, Saw Tooth Distortion, Evolutionary Prototype (EP), Duality ZF, Decimation X, Decimation X2,
Decimation X3, Decimation X3.5, Decimation X4, Score Rush, Score Rush 2, Score Rush (HTML5), Score Rush MP, and Score Rush Extended (Score Rush EX)
trademarked and copyrighted by Xona Games Inc., Matthew Doucette, and/or Jason Doucette.
© 2000..2005 Saw Tooth Distortion. © Xona.com. © 2008..2010 Xona Games (under Xona.com).
© Xona Games Inc.
We make Intense Retro video games.