1.2.3-SNAPSHOT permalink Arrow_down_16x16

minkowski-distance

incanter.stats

  • (minkowski-distance a b p)
http://en.wikipedia.org/wiki/Minkowski_distance
http://en.wikipedia.org/wiki/Lp_space

The Minkowski distance is a metric on Euclidean space which can be considered as a generalization of both the Euclidean distance and the Manhattan distance.

Minkowski distance is typically used with p being 1 or 2. The latter is the Euclidean distance, while the former is sometimes known as the Manhattan distance.

In the limiting case of p reaching infinity we obtain the Chebyshev distance.

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:2931 top

(defn minkowski-distance
"http://en.wikipedia.org/wiki/Minkowski_distance
http://en.wikipedia.org/wiki/Lp_space

The Minkowski distance is a metric on Euclidean space which can be considered as a generalization of both the Euclidean distance and the Manhattan distance.

Minkowski distance is typically used with p being 1 or 2. The latter is the Euclidean distance, while the former is sometimes known as the Manhattan distance.

In the limiting case of p reaching infinity we obtain the Chebyshev distance."
 [a b p]
(let [_ (assert (= (count a) (count b)))]

 (pow
  (apply
   tree-comp-each
   + 
  (fn [[x y]] 
    (pow 
     (abs 
      (- x y)) 
     p))
  (map vector a b))
  (/ 1 p))))
Vars in incanter.stats/minkowski-distance: + - / apply defn fn let map vector
Used in 0 other vars

Comments top

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