Concept

Hamming Distance

The Hamming distance is a metric useful for comparing categorical variables. It measures distance by counting the number of positions at which corresponding elements differ. For each position, if the two elements are the same, the difference is 0; if they are different, the difference is 1. Its formula is given by: DH=i=1kxiyiD_H = \sum_{i=1}^k |x_i - y_i| where xiyi=0|x_i - y_i| = 0 if xi=yix_i = y_i, and xiyi=1|x_i - y_i| = 1 if xiyix_i \neq y_i.

0

2

Updated 2026-06-14

Tags

Data Science