How do you use a Monte Carlo method to approximate the area enclosed by the circle.
-
$\begingroup$ Did you see these items mathematica.stackexchange.com/questions/37074/… and mathematica.stackexchange.com/questions/35683/…? $\endgroup$– MooSep 12, 2019 at 1:40
2 Answers
Literally the Monte Carlo Method
:
reg = RegionIntersection[Disk[], Disk[{1, 1}, 2]];
NIntegrate[1, {x, y} \[Element] reg, Method -> "MonteCarlo"]
(* 2.59499 *)
rndPts = Table[RandomReal[{-3, 3}],{10^6},{2}];
9 Length[Select[
rndPts, #[[1]]^2 + #[[2]]^2 >
1 && (#[[1]] - 1)^2 + (#[[2]] - 1)^2 < 4 &]]/Length[rndPts]
2.51295