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 70
70
//! println!("{}", tuple)
71
71
//! ```
72
72
//!
73
- //! ## Monte Carlo estimation of pi
73
+ //! ## Monte Carlo estimation of π
74
74
//!
75
75
//! 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:
78
78
//!
79
79
//! ```notrust
80
- //! (area of unit circle) / (area of square)
80
+ //! (area of unit circle) / (area of square) = π / 4
81
81
//! ```
82
82
//!
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.
85
85
//!
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
87
87
//! square at random, calculate the fraction that fall within the circle, and
88
88
//! multiply this fraction by 4.
89
89
//!
You can’t perform that action at this time.
0 commit comments