It would be good to add a small number like epsilon = 0.000000001 or something to the pdistfcm function and whenever you have a denominator that could be 0.
def pdistfcm(cntr, data):
out = np.zeros(shape=(cntr.shape[0], data.shape[0]))
for k in range(cntr.shape[0]):
out[k] = np.sqrt(np.sum((np.power(data-cntr[k], 2)).T, axis=0)) + 0.000000000001 #add eps to avoid divide by 0
return out
It would be good to add a small number like epsilon = 0.000000001 or something to the pdistfcm function and whenever you have a denominator that could be 0.