1

Suppose that in a nxn grid, we choose a lattice point and took the sum of the distances from that point to every other lattice point in the grid (including the edge points) and then divide the sum by n^2. We then do the same thing so that the "center" is at another point and do this for all points in the grid and take the average. Let a_n be defined as the average for the nxn grid multiplied by 2/n. I ran a python script and from the first 75 terms in this sequence, it looks like it's converging to 1.043 or it's just diverging very slowly. Does the sequence converge and is there a way to find an explicit formula for a_n?

def center_Distance(n,m, x, y):
total = 0
for i in range(n):
    for j in range(m):
        total += ((x-i)**2 + (y-j)**2)**0.5
return total/(n*m)

li = [] mi = [] M = 75 for i in range(1, M): #li will contain the sum of the distances for each center

li = [] for k in range(i): for m in range(i): li.append(center_Distance(i, i, k, m))

# find average of li and multiply by 2/i
total = 2*sum(li)/(len(li)*i)
print(total)

snowball
  • 159
  • I'm having difficulty understanding the sentence: "... so that the center is at another point...". It's unclear if you are: (a) finding the mean distance distance of all grid points to one point, then the mean distance to one other point, and averaging these two numbers, or (b) if you are finding the mean distance of all grid points to one point, then repeating this for all grid points. Presumably this could be inferred by studying the code, but it would help if you described it – Sal Mar 10 '21 at 15:36
  • 1
    sorry about the confusion. I meant (b). So it would be finding the mean distance of all grid points to one point, then repeating this for all grid points and then taking the average of all of these mean distances. – snowball Mar 10 '21 at 15:50

1 Answers1

0

This is not really an answer (especially since it doesn't contain any work of my own), but too long and unwieldy for a comment: This is essentially the average distance of two points in an $n\times n$-grid. Why it's multiplied by $2/n$ in the end, I can't say, multiplying by $1/n$ (giving a value of about $0.521$ in the limit) would reduce it to the average distance of two points in a unit square with a discrete uniform distribution. As $n\to\infty$, we can expect it to converge to the average distance of two points independently uniformly distributed in the unit square, and that is known: Average distance between two randomly chosen points in unit square (without calculus)

qfwfq
  • 174