fatf.utils.distances
.hamming_distance_base¶

fatf.utils.distances.
hamming_distance_base
(x: str, y: str, normalise: bool = False, equal_length: bool = False) → Union[int, float][source]¶ Calculates the Hamming distance between two strings
x
andy
.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
andy
.
 Raises
 TypeError
Either
x
ory
is not a string. ValueError
x
andy
are of different length whenequal_length
parameter is set toTrue
.