Skip to content

Commit

Permalink
Use unicode pi symbol in pi estimation example. Additional tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
nham committed Aug 21, 2014
1 parent 3481321 commit 8658722
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/libstd/rand/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//!
Expand Down

5 comments on commit 8658722

@bors
Copy link
Contributor

@bors bors commented on 8658722 Aug 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from huonw
at nham@8658722

@bors
Copy link
Contributor

@bors bors commented on 8658722 Aug 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nham/rust/std_rand_pi_example = 8658722 into auto

@bors
Copy link
Contributor

@bors bors commented on 8658722 Aug 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nham/rust/std_rand_pi_example = 8658722 merged ok, testing candidate = 5305f9b

@bors
Copy link
Contributor

@bors bors commented on 8658722 Aug 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 5305f9b

Please sign in to comment.