I have been trying to program a math formula in python. The code is running but I have strong belief that the code is not reflecting the actual math formulas,but I am so lost I don't know where I could have gone wrong. Below is my code and I have attached the actual maths formula. Please check if the python code matches the math formula -if not, assist on where I am going wrong. I am honestly so lost.
## Inter cluster distance
inter = 0
for i in range(centr.shape[1]-1):
for j in range(i+1,centr.shape[1]):
for l in range(centr.shape[0]):
inter = inter + (centr[l][i]-centr[l][j])**2
print('Intercluster distance: '+ str(inter))
## Intra cluster cluster
intra = 0
for i in range(data.shape[0]):
for j in range(centr.shape[0]):[enter image description here][2]
intra = intra + (data[i][j] - centr[j][Cc[i]-1])**2
print('Intracluster distance: '+ str(intra))
Math equation intra-cluster distance Mth equation inter-cluster distance

