Is there a mathematical formula for the Gestalt Law of Proximity?

I would like to know if there are any mathematical formulas that define the Gestalt Law of Proximity. example of law of proximity

For example, in the picture above, at what distance of Y would the 4th square be perceived not a part of the group?

------ Update: I apologize for not giving enough details in the question earlier

  1. The context is for on-screen elements, say on a website, so all 3D attributes, viewing angle can be discounted.
  2. Assume the elements are identical to one another. Same colour, shape, size, border, etc...
  3. The only differentiating factor is the PROXIMITY.