Hamming distance
For text or other non-numeric data, metrics such as the Hamming distance or Levenshtein distance are often used.