1.2.3-SNAPSHOT Arrow_down_16x16

hamming-distance

incanter.stats

  • (hamming-distance a b)
http://en.wikipedia.org/wiki/Hamming_distance

In information theory, the Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. Put another way, it measures the minimum number of substitutions required to change one string into the other, or the number of errors that transformed one string into the other.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source incanter/stats.clj:3112 top

(defn hamming-distance
"http://en.wikipedia.org/wiki/Hamming_distance

In information theory, the Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. Put another way, it measures the minimum number of substitutions required to change one string into the other, or the number of errors that transformed one string into the other."
[a b]
(if (and (integer? a) (integer? b))
  (hamming-distance (str a) (str b))
(let [_ (assert (= (count a) (count b)))]
(apply
 tree-comp-each 
  + 
  #(bool-to-binary (not (apply = %)))
  (map vector a b)))))
Vars in incanter.stats/hamming-distance: + = and apply defn integer? let map not str vector
Used in 0 other vars

Comments top

No comments for hamming-distance. Log in to add a comment.