I use the following (based on ideas and functions I got as ansers in [1], [2] by, repsectively, @ybeltukov and @J.M.) in order to find random circles with centers inside a unit square that intersect this square.
findPoints =
Compile[{{n, _Integer}, {low, _Real}, {high, _Real}, {minD, _Real}},
Block[{data = RandomReal[{low, high}, {1, 2}], k = 1, rv, temp},
While[k < n, rv = RandomReal[{low, high}, 2];
temp = Transpose[Transpose[data] - rv];
If[Min[Sqrt[(#.#)] & /@ temp] > minD, data = Join[data, {rv}];
k++;];];
data]];
npts = 150;
r = 0.03;
minD = 2.2 r;
low = 0;
high = 1;
SeedRandom[159];
Timing[pts = Select[findPoints[npts, low, high, minD],
Area[ImplicitRegion[((x - #[[1]])^2 + (y - #[[2]])^2 <=
r^2) && ! (0 < x < 1 && 0 < y < 1), {x, y}]] != 0 &];]
(* {8.68383, Null}*)
pts // Length
(*33*)
g2d = Graphics[{FaceForm@Lighter[Blue, 0.8],
EdgeForm@Directive[Thickness[0.004], Black], Disk[#, r] & /@ pts},
Background -> Lighter@Gray, Frame -> True,
PlotRange -> {{low, high}, {low, high}}]
As we notice the function that finds pts is not the best one regarding time efficiency (this is in contrast with the clever original approach of J.M.).
1) Any suggestion in order to decrease this timing?
2) As a second question, how we can depict only the part of the circles that lie within the square?
Thanks.

