| ▲ | spankalee a day ago |
| Generating 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;
|
|
| ▲ | arijun a day ago | parent | next [-] |
| Wait, 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. |
| |
| ▲ | Jtsummers a day ago | parent | next [-] | | Squaring 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 a day ago | parent [-] | | Oh yes all of you are right. In my defense, I am stupid. |
| |
| ▲ | a day ago | parent | prev | next [-] | | [deleted] | |
| ▲ | hhmc a day ago | parent | prev | next [-] | | Because the numbers are less than 1 sqrt pulls them towards 1 (the edge) | |
| ▲ | hatthew a day ago | parent | prev [-] | | assuming random() returns values 0<=r<=1, sqrt will shift the distribution outward |
|
|
| ▲ | hatthew a day ago | parent | prev [-] |
| Yeah that would be at least nontrivial, but has been written about so much that the bar for a worthwhile article seems pretty high. |