I can generate a 2D random number within a square region, say $\{x,y\} \in [p_i,p_f]$, using
rand = RandomReal[{pi, pf}, 2];
I now would like to get a random number in this region but outside the sphere centered around a and with radius r with a+r<pf and a-r>pi.
In this thread various ways of generating random numbers inside a region are discussed. However, I couldn't figure out how to modify the responses to solve my problem.


RandomPointwith an appropriate region (look upRegionDifference). Obviously, the region you use must be of finite size. If this did not work, be specific about where you got stuck. – Szabolcs Jun 09 '22 at 17:45RandomPoint[Disk[], 1]to generate a random number inside a Disk but how can I generate a number outside this Disk? – Shasa Jun 09 '22 at 17:50