# Evaluate area of random region covered by disks

If I cover a square of side $$L$$ with $$n$$ unit disks at random (the disks may overlap the boundary), is there a standard way to evaluate the total covered area $$A$$?

I am looking to observe the density $$f_{A}(x)$$.

I am thinking to use implicit region, with the distance to at least one disk centre lesson than 1, but how to you evaluate the area? • r1 = Region[Disk[]] RegionMeasure[r1] gives $\pi$.
– Syed
Nov 19, 2021 at 17:14
• Ok so just apply this to Region[...] of a set of random disks?
– apg
Nov 19, 2021 at 17:20
• Not Mathematica tip, but check out section "A Generalized Niche Model" in this article. Nov 19, 2021 at 19:03
• Highly relevant because it should describe the most performant(?) algorithm known: Edelsbrunner: The Union of Balls and Its Dual Shape. Nov 20, 2021 at 11:32
• With that accuracy you want the answer? Would the share of black pixels on the picture suffice? Nov 20, 2021 at 20:49

This code will produce a histogram of the random area. It is a bit slow, perhaps someone knows how to speed it up.

area[n_] := Module[{c, r1}, c = RandomReal[{-2, 2}, {n, 2} ];
RegionMeasure[
RegionIntersection[{Rectangle[{-3, -3}, {3, 3}],
RegionUnion[Disk[#, 1] & /@ c]}]]]
Histogram[Table[36 - area, {i, 1, 100}], {1}]; c = RandomReal[{-2, 2}, {10, 2} ];
RegionPlot[RegionIntersection[{Rectangle[{-3, -3}, {3, 3}],
RegionUnion[Disk[#, 1] & /@ c]}]] • You don't take into account the condition" a square of side $L$". Your RegionPlot differs from the plot in the question. To this end it is enough to take the intersection with a given square in your Module. Nov 19, 2021 at 20:46
• Updated, had altered the code for second figure
– apg
Nov 19, 2021 at 22:11
• Also to demonstrate the "edge" cases, you can have circles closer to the edges and partly outside the rectangular area.
– Syed
Nov 20, 2021 at 6:47
• It should be RandomReal[{-3, 3}, {n, 2} ] in your code to satisfy the request in the question. Nov 20, 2021 at 12:16