Distance measures

Examples of implementations of different distance measures. When I have some time I will elaborate on their usage.

#Simple matching coeficient
def smc(sdr1, sdr2):
	n11 = (sdr1 & sdr2).count()
	n00 = (~sdr1 & ~sdr2).count()
	return float(n11+n00)/len(sdr1)

def jiccard(sdr1,sdr2):
	n11 = (sdr1 & sdr2).count()
	n01_10 = (sdr1 ^ sdr2).count()
	return n11/float(n01_10+n11)


def cosine_similarity(vector,matrix):
	sim = ( np.sum(vector*matrix,axis=1) / ( np.sqrt(np.sum(matrix**2,axis=1)) * np.sqrt(np.sum(vector**2)) ) )[::-1]
	return sim

def euclidean_distance(vector, matrix):
	dist = np.sqrt(np.sum((vector - matrix)**2,axis=1))
	#dist = np.linalg.norm(vector - matrix, axis=1)
	return dist