[][src]Module smartcore::math::distance::hamming

Hamming Distance between two strings is the number of positions at which the corresponding symbols are different.

Hamming Distance

Hamming Distance measures the similarity between two integer-valued vectors of the same length. Given two vectors \( x \in ℝ^n \), \( y \in ℝ^n \) the hamming distance between \( x \) and \( y \), \( d(x, y) \), is the number of places where \( x \) and \( y \) differ.

Example:

use smartcore::math::distance::Distance;
use smartcore::math::distance::hamming::Hamming;

let a = vec![1, 0, 0, 1, 0, 0, 1];
let b = vec![1, 1, 0, 0, 1, 0, 1];

let h: f64 = Hamming {}.distance(&a, &b);

Structs

Hamming

While comparing two integer-valued vectors of equal length, Hamming distance is the number of bit positions in which the two bits are different