Use unicode pi symbol in pi estimation example. Additional tweaks

This commit is contained in:
nham 2014-08-21 02:42:15 -04:00
parent 348132196a
commit 86587224d0
1 changed files with 7 additions and 7 deletions

View File

@ -70,20 +70,20 @@
//! println!("{}", tuple)
//! ```
//!
//! ## Monte Carlo estimation of pi
//! ## Monte Carlo estimation of π
//!
//! For this example, imagine we have a square with sides of length 2 and a unit
//! circle, both centered at the origin. Since the area of a unit circle is pi,
//! the ratio
//! circle, both centered at the origin. Since the area of a unit circle is π,
//! we have:
//!
//! ```notrust
//! (area of unit circle) / (area of square)
//! (area of unit circle) / (area of square) = π / 4
//! ```
//!
//! is equal to pi / 4. So if we sample many points randomly from the square,
//! roughly pi / 4 of them should be inside the circle.
//! So if we sample many points randomly from the square, roughly π / 4 of them
//! should be inside the circle.
//!
//! We can use the above fact to estimate the value of pi: pick many points in the
//! We can use the above fact to estimate the value of π: pick many points in the
//! square at random, calculate the fraction that fall within the circle, and
//! multiply this fraction by 4.
//!