public class MonteCarlo extends Object
sqrt(x^2 + y^2) < rsince the radius is 1.0, we can square both sides and avoid a sqrt() computation:
x^2 + y^2 ≤ 1.0this area under the curve is (Pi * r^2)/ 4.0, and the area of the unit of square is 1.0, so Pi can be approximated by
# points with x^2+y^2 < 1 Pi =~ -------------------------- * 4.0 total # points
Constructor and Description |
---|
MonteCarlo() |
Modifier and Type | Method and Description |
---|---|
static double |
integrate(int Num_samples) |
static double |
num_flops(int Num_samples) |
Copyright © 2018. All rights reserved.