News Feed
Jobs Feed
Sections




News Archive
Tobias Schlitt's Blog:
Randomized Pi calculation
April 02, 2007 @ 10:04:00

Since there is no "magic variable" to get a value for Pi in an application, Tobias Schlitt offers up the next best thing - his homegrown solution for creating the value (using a randomized variation).

I don't know which is the most common way to calculate Pi in computer programs, but from the stochastics book a read for my recent stochastics exam, I have a randomized variation, which is quite cool I think.

The code example is included along with a bit of explanation for those not familiar with the concepts behind it. It uses two of PHP functions, pow() and mt_rand(), to run through a series of iterations and, using a preset precision value, find the "hits" to finally calculate the value at the end.

1 comment voice your opinion now!
randomize pi calculation pow mtrand precision randomize pi calculation pow mtrand precision


blog comments powered by Disqus

Similar Posts

SitePoint.com: How to Create Your Own Random Number Generator in PHP

Tobias Schlitt's Blog: Randomized Pi calculation

Syntux Blog: Advanced Caching Technique - Block Randomization

Tobias Schlitt's Blog: Randomized Pi calculation

Jonathan Street's Blog: Random thoughts on random strings


Community Events











Don't see your event here?
Let us know!


language object testing framework series zendframework2 conference database podcast composer opinion interview functional development introduction tool release code community example

All content copyright, 2013 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework