File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change 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//!
You can’t perform that action at this time.
0 commit comments