Is there a mathematical formula for the law of proximity of the Gestalt?

I would like to know if there are mathematical formulas defining the law of proximity of the Gestalt.
example of proximity law

For example, in the image above, how far from Y would the 4th square be perceived outside the group?