Non-random uniform disk sampling
victorpoughon.fr
victorpoughon.fr
[1] https://en.wikipedia.org/wiki/Low-discrepancy_sequence
[2] https://extremelearning.com.au/unreasonable-effectiveness-of...
It's surprising how hard a time I've had googling this problem. Surely I'm far from the first to wonder about it. I think a mix of AI enshittification, and the ambiguous meanings of "sampling" and "uniform" made it hard to find good material on it.
https://stats.stackexchange.com/questions/481543/generating-...
[1] I took a class on numerics taught by one of the authors; great book but it's a shame about the software license
Although in 2 dimensions (setting of OP), this isn't that bad (you waste a proportion of (1-pi/4), or 21%, of your samples) -- perhaps 21% might be worth worrying about for some applications.
Of course, it gets much worse in higher dimensions, because the unit ball is much smaller than the unit cube there.
EDIT: but for large N these things probably don’t matter that much. And I guess that’s the application in the end.
http://hydra.nat.uni-magdeburg.de/packing/cci/d1.html
and the other cases are nearby.
btw what are the colors indicating on that page? its missing a legend and its not immediately obvious to me.
And there may be differently-arranged also-optimal packings - e.g. for N = 18 there are others besides what is shown.
Here is an introduction for those curious: https://towardsdatascience.com/unit-disk-uniform-sampling-91...
A copy of the original paper can be found here and is nice and easy to read, with pseudocode: https://web.archive.org/web/20190223095317id_/http://pdfs.se...
Alternatively for the non-random and arbitrary N case here, an approach based on Phyllotaxis that samples a Fermat spiral every ~137.508 degrees (i.e., the golden angle, or the golden ratio fraction of a circle) also works pretty well: https://en.wikipedia.org/wiki/Fermat%27s_spiral#The_golden_r.... It works nicely for any N, even if the N isn't square or close to square (just choose the scaling appropriately, e.g., c = 1/sqrt(N)).
We do? I think this is the latest state of the research here — only 14 Ns are proven optimal and it's certainly nowhere close to a general algorithm: http://hydra.nat.uni-magdeburg.de/packing/cci/
There's something to be said for a dozen lines of numpy that gets "close enough". That said, I do think there should be something better.
First as other pointed out, one can generate the Sobol sequence or similar, but even with a random sample one can generate the random numbers deterministically. I.e Sample r^2 ~ Uniform(0,r0^2) and angle from U(0,2*pi) and use the fixed seed...
I agree that filtering the Sobol sequence, or other low-discrepancy sequence, would be another path to a solution.