3 ms·
Tips: The source code can be seen by clicking on '</>'; The random() function takes an upper limit of a desired uniform distribution (from 0 to x), this shows t
by gnramires 3y ago
Tips: The source code can be seen by clicking on '</>'; The random() function takes an upper limit of a desired uniform distribution (from 0 to x), this shows the effect of the distribution of those iterated random functions.
I think this isn't so intuitive because the polar coordinates already imply greater density near center (which could be corrected with a suitable map).
- acjohnson55 3y agoThe reason it's counterintuitive is because the randomly chosen distance variable is 1 minus the nested randoms. Each random call becomes the upper bound of future random calls, so the more times you nest it, the closer to zero you're likely to be. Subtracting that from one puts you close to the unit circle.
- em-bee 3y agoright, if the points are distributed in a square then the distribution looks more like what one would expect: (i am to lazy to register to make a fork, here is the code change): replace: let a = random(Math.PI*2); let r = d * (1 - random()); point(cos(a)*r, sin(a)*r); with: let x = random(d); let y = d * (1 - random()); point(x, y); in every block you could even simplify it to: let x = random(d); let y = random(d); point(x, y); and for more fun apply the nested random() call to both axis: let x = random(random(d)); let y = random(random(d)); point(x, y);
- SamBam 3y agoYup, that's way more intuitive, and removes the artifact of the first circle looking like the points are clustered around the middle: I forked it: https://openprocessing.org/sketch/1929579 https://openprocessing.org/sketch/1929579