RandomPointIn isn't uniform with area

ethicalnerd shared this problem 2 years ago
Solved

Using RandomPointIn("the unit circle") clusters the points near the center of the circle. To get uniform points, I have to generate pairs of r = sqrt(random()) and theta = 2*pi*random().

Comments (7)

photo
1

It doesn't seem so bad to me in my test file. :)

/HyNrJ+VQC3IIAAAAAElFTkSuQmCC

photo
1

If you want, you can play with this command, too https://wiki.geogebra.org/e...

photo
1

not for me

/wGS0PM3Oaf87wAAAABJRU5ErkJggg==/Azj7aC7L1fYUAAAAAElFTkSuQmCC

I think the points are generated r = random() and theta = 2*pi*random() instead r = sqrt(random()) and theta = 2*pi*random()

photo
1

I've made a couple of trials again, using CAS and more digits, too.And confirm clustering in (0,0) - I stopped too early in my first attempt :(

This maybe explains the whole thing: http://mathworld.wolfram.co...

Then the command itself, meant for "general purpose" on different kind of regions, fails in this case - and probably others, depending on the properties of the region.

photo
1

Thanks, we'll see if we can improve that at some point

photo
1

y creo que hay un bug

los puntos aleatorios en una elipse están situados sobre una elipse girada con ejes vertical y horizontal y con mayor densidad de puntos cerca de los ejes

/g9EalvK6Zv8BgAAAABJRU5ErkJggg==

photo
1

Sorry for the delay - this will be fixed very soon (probably for v600)

© 2021 International GeoGebra Institute