mljs / distance

Distance functions to compare vectors
https://mljs.github.io/distance/
MIT License
65 stars 4 forks source link

Implement Hamming distance #9

Open opatiny opened 1 year ago

opatiny commented 1 year ago

The Hamming distance can typically be used to compute the distance between two bit strings very easily, by doing sum(xor(a,b)). It counts the number of dissimilar elements between the strings. It can be used as a distance measurement for feature matching.

https://en.wikipedia.org/wiki/Hamming_distance

lpatiny commented 1 year ago

Should get inspired by Tanimoto: https://github.com/mljs/distance/blob/master/src/similarities/tanimoto.js Take care than tanimoto has this flag 'bitvector' to specifiy that the a and b parameters are array (of uint32 I guess).