fatf.utils.distances.hamming_distance_base

fatf.utils.distances.hamming_distance_base(x, y, normalise=False, equal_length=False)[source]

Calculates the Hamming distance between two strings x and y.

If the strings are of a different length they are compared up to the shorter one’s length and the distance between them is increased by their difference in length.

Parameters
xstring

The first string to be compared.

ystring

The second string to be compared.

normaliseboolean, optional (default=False)

Normalises the distance to be bounded between 0 and 1.

equal_lengthboolean, optional (default=False)

Forces the arrays to be of equal length – raises exception if they are not.

Returns
distanceNumber

The Hamming distances between x and y.

Raises
TypeError

Either x or y is not a string.

ValueError

x and y are of different length when equal_length parameter is set to True.