Estimating π with Monte Carlo
First, we will apply our new knowledge of cuRAND to perform an estimate of the well-known mathematical constant π, or Pi, which is, of course, the never-ending irrational number 3.14159265358979...
To get an estimate, though, we need to take a moment to think about what this means. Let's think about a circle. Remember that the radius of a circle is the length from the center of the circle to any point in the circle; usually, this is designated with R. The diameter is defined as D = 2R, and the circumference C is the length around the circle. Pi is then defined as π = C / D . We can use Euclidean geometry to find a formula for the area of the circle, which turns out being A = πR2 . Now, let's think about a circle ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access