Skip to content

Commit 8658722

Browse files
committed
Use unicode pi symbol in pi estimation example. Additional tweaks
1 parent 3481321 commit 8658722

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/libstd/rand/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,20 @@
7070
//! println!("{}", tuple)
7171
//! ```
7272
//!
73-
//! ## Monte Carlo estimation of pi
73+
//! ## Monte Carlo estimation of π
7474
//!
7575
//! For this example, imagine we have a square with sides of length 2 and a unit
76-
//! circle, both centered at the origin. Since the area of a unit circle is pi,
77-
//! the ratio
76+
//! circle, both centered at the origin. Since the area of a unit circle is π,
77+
//! we have:
7878
//!
7979
//! ```notrust
80-
//! (area of unit circle) / (area of square)
80+
//! (area of unit circle) / (area of square) = π / 4
8181
//! ```
8282
//!
83-
//! is equal to pi / 4. So if we sample many points randomly from the square,
84-
//! roughly pi / 4 of them should be inside the circle.
83+
//! So if we sample many points randomly from the square, roughly π / 4 of them
84+
//! should be inside the circle.
8585
//!
86-
//! We can use the above fact to estimate the value of pi: pick many points in the
86+
//! We can use the above fact to estimate the value of π: pick many points in the
8787
//! square at random, calculate the fraction that fall within the circle, and
8888
//! multiply this fraction by 4.
8989
//!

0 commit comments

Comments
 (0)