Numerosity task

Hello,

i would like to run a numerosity task:

  • 2 black circles side by side
  • each circle containing a set of white dots (random position)
    where the number and size of dots in each circle can be adjusted.

Is there a simple way to code this task, or should i built it from scratch? If so, hints would be much welcome?

Thanks in advance
best,
thibault

For any task, the meaning of “random” needs to be carefully defined. In this case, because the randomness is in two dimensions, with a circular boundary, the need for precision in the description is even higher.

You are absolutely correct. What matters is that there is no obious pattern in the disposition of the dots, and that they are that there is no overlap. So i see two possible ways.

  • to use two random numbers to define the position of one point (raduis and angle), and then to iterate until there is a minimal distance between each points.

  • to first define an array of possible coordinates, and then to randomly assign each points to a position.

Best
thibault

This is a possibility, but isn’t straight forward. One can sample from the angles as a uniform distribution, but then the points get spread further apart as they get further from the centre of the circle. If you want a uniform spatial distribution across the area of the circle, I think the solution is something about sampling the radial value with the square root as the upper value, and then squaring the result?

But then avoiding collisions and overlaps is a a laborious task.

This is far simpler to achieve, as it can de done in a deterministic way, without the iterations required to avoid overlaps. So you need to define the size and layout of the array.

With respect to placing dots within a circle and keeping the distribution uniform. It makes sense to use polar coordinates and therefore pick the radius r between 0 and the radius of the region, and then pick an angle between 0 and 360. However, this means the dor distribution is not uniform, there will be uniform dots within a band, but different densities near the centre and farther out. However this can be fixed. The radius r, should not be chosen from a uniform distribution, but one that goes as pdf_r = (2/R^2)r. That is you take the inverse of the cumulative distribution, so r = Rsqrt( rand()).
More details here: http://www.anderswallin.net/2009/05/uniform-random-points-in-a-circle-using-polar-coordinates/
Of course you don’t have this problem if you pick x and y and then reject those locations that are outside the circular region.

Cheers, Marco

1 Like

Dear Marco,

thank you very much for the details!

best

thibault