4 ms·
I doubt I'm more geometrically inclined than the average HN user, but to me the general "accept-flip" method mentioned here seems trivial, obvious, and already
by hatthew 1y ago
I doubt I'm more geometrically inclined than the average HN user, but to me the general "accept-flip" method mentioned here seems trivial, obvious, and already solved, to the extent that I'm surprised it's worth writing more about or considering any alternatives.
- spankalee 1y agoGenerating random points uniformly in a circle without rejection is at least mildly more interesting, as you need to scale one factor by a square root: const r = sqrt(random()) * radius; const theta = random() * TAU;
- hatthew 1y agoYeah that would be at least nontrivial, but has been written about so much that the bar for a worthwhile article seems pretty high.
- arijun 1y agoWait, wouldn't this result in the opposite of what you want? You want to shift the distribution out, not crowd the center, so you probably want to square your random instead.
- hatthew 1y agoassuming random() returns values 0<=r<=1, sqrt will shift the distribution outward
- Jtsummers 1y agoSquaring numbers in (0,1) makes them smaller, pulling the random radius closer to center. As an example consider 0.9. Squaring it gets 0.81 vs 0.949 taking the square root.
- arijun 1y agoOh yes all of you are right. In my defense, I am stupid.
- hhmc 1y agoBecause the numbers are less than 1 sqrt pulls them towards 1 (the edge)
- deleted 1y ago[deleted]
- hk__2 1y agoObligatory xkcd: https://xkcd.com/1053/ https://xkcd.com/1053/