diff options
| author | nham <hamann.nick@gmail.com> | 2014-08-21 02:42:15 -0400 |
|---|---|---|
| committer | nham <hamann.nick@gmail.com> | 2014-08-21 02:42:15 -0400 |
| commit | 86587224d0b99c69da01ebfaf98052694036302b (patch) | |
| tree | f30500d285cf24935874cc7b2757cbea01a345f7 /src/libstd | |
| parent | 348132196a1a25336d2df6b6e0989540cdc8f7e1 (diff) | |
| download | rust-86587224d0b99c69da01ebfaf98052694036302b.tar.gz rust-86587224d0b99c69da01ebfaf98052694036302b.zip | |
Use unicode pi symbol in pi estimation example. Additional tweaks
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/rand/mod.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 00abd84d5c2..0739d91b584 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -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. //! |
