fastmath.distance
Distance objects.
Objects implement IFn, Smile and Apache Commons Math distance interfaces.
angular
Angular distance
Examples
Usage
(angular [1 2 4 4] [-1 3 4 -5])
;;=> 0.4926717117557925
bound
(bound distance)
(bound distance diameter)
Create relative distance function to be bound by a diameter
(default: by 1.0
).
correlation
Correlation distance
Examples
Usage
(correlation [1 2 4 4] [-1 3 4 -5])
;;=> 1.094551438155196
cosine
Cosine similarity
Examples
Usage
(cosine [1 2 4 4] [-1 3 4 -5])
;;=> 0.023020462775806542
earth-movers
Earth-Movers distance
Examples
Usage
(earth-movers [1 2 4 4] [-1 3 4 -5])
;;=> 14.0
euclidean
Euclidean distance
Examples
Usage
(euclidean [1 2 4 4] [-1 3 4 -5])
;;=> 9.273618495495704
euclidean-sq
Squared Euclidean distance
Examples
Usage
(euclidean-sq [1 2 4 4] [-1 3 4 -5])
;;=> 86.0
jensen-shannon
Jensen-Shannon distance
Examples
Usage
(jensen-shannon [1 2 4 4] [1 3 4 5])
;;=> 0.27959614036771147
make-mahalanobis
(make-mahalanobis cov)
Create Mahalonobis distance for given covariance (seq of seqs) matrix.
Examples
Usage
(let [cov (stats/covariance-matrix [[1 2 4 4] [-1 3 4 -5]])
d (make-mahalanobis cov)]
(d [1 2] [3 4]))
;;=> 1.4683705013748423
make-minkowski
(make-minkowski p weights)
(make-minkowski p)
Create Minkowski distance for order p
and optional weights
for each dimension.
Examples
Usage
(let [d (make-minkowski 0.5)] (d [1 2 4 4] [-1 3 4 -5]))
;;=> 29.313708498984774
(let [d (make-minkowski 3.0)] (d [1 2 4 4] [-1 3 4 -5]))
;;=> 9.036885658095787
(let [d (make-minkowski 2.0 [0.1 0.2 0.4 0.3])]
(d [1 2 4 4] [-1 3 4 -5]))
;;=> 4.989989979949861
shoenberg-transform
(shoenberg-transform distance)
(shoenberg-transform distance lambda)
Create relative distance function by applying Shoenberg transform.