## DefinitionEdit

Given two squences (or strings) of symbols in an alphabet $\mathcal{L}$, the Hamming distance is a function that measures the number of positions for which the corresponding symbols are different,

$\sigma(s,t)=\frac{\sum_{i=1}^{\min\{|s|,|t|\}}\sigma_{id}(s[i],t[i])}{\max\{|s|,|t|\}},$

where $\sigma_{id}$ is the identity similarity

Failed to parse (lexing error): \sigma_{id}(s[i],t[i])\left\{% \begin{array}{ll} 1, & \hbox{si $s[i]=t[i]$;} \\ 0, & \hbox{si $s[i]\neq t[i]$.} \\\end{array}% \right.

## Examples Edit

• HammingSim('house','horse') = 3/5 = 0.6.
• HammingSim('abcd',' ') = 0/4 = 0.
• HammingSim('abcd','a') = 1/4 = 0.25.
• HammingSim('abcd','b') = 0/4 = 0.25.
• HammingSim('id0345','id1352') = 3/6 = 0.5.

## Normalization Edit

It is normalized.

## Applications Edit

Useful for comparing codes.