• incanter

# lee-distance

## incanter.stats

• (lee-distance a b q)
http://en.wikipedia.org/wiki/Lee_distance

In coding theory, the Lee distance is a distance between two strings x1x2...xn and y1y2...yn of equal length n over the q-ary alphabet {0,1,…,q-1} of size q >= 2. It is metric.

If q = 2 or q = 3 the Lee distance coincides with the Hamming distance.

The metric space induced by the Lee distance is a discrete analog of the elliptic space.

### Source incanter/stats.clj:3127 top

```(defn lee-distance
"http://en.wikipedia.org/wiki/Lee_distance

In coding theory, the Lee distance is a distance between two strings x1x2...xn and y1y2...yn of equal length n over the q-ary alphabet {0,1,‚Ä¶,q-1} of size q >= 2. It is metric.

If q = 2 or q = 3 the Lee distance coincides with the Hamming distance.

The metric space induced by the Lee distance is a discrete analog of the elliptic space.
"
[a b q]
(if (and (integer? a) (integer? b))
(lee-distance (str a) (str b) q)
(let [_ (assert (= (count a) (count b)))]
(apply
tree-comp-each
+
(fn [x]
(let [diff (abs (apply - (map int x)))]
(min diff (- q diff))))
(map vector a b)))))```
Vars in incanter.stats/lee-distance: + - and apply defn fn integer? let map min str vector
Used in 0 other vars