Distances

Distances.jl is a Julia package for calculating distance metrics between vectors, including pairwise and column-wise calculations.

github.com/JuliaStats/Distances.jl
Distances homepage screenshot

About Distances

Distances.jl is a Julia package for evaluating distance metrics between vectors and other iterables of known size. It covers a broad set of metrics, including Euclidean, Cityblock, Chebyshev, Minkowski, Hamming, Jaccard, cosine, correlation, Mahalanobis, Hellinger, Haversine, Kullback-Leibler, Rényi and Jensen-Shannon, among others, and offers weighted variants for several of them.

Beyond single-vector comparison, the package provides colwise and pairwise routines for 2D arrays, which the project describes as often substantially faster than straightforward loop implementations. Results can be written into preallocated arrays using in-place variants, and distance type instances or convenience functions can be used for evaluation.

Key features

  • Computes distances between two equal-length vectors or iterables
  • Supports many metrics including Euclidean, cosine, Hamming, Jaccard and Mahalanobis
  • Column-wise batch computation between corresponding matrix columns
  • Pairwise distance matrices via dims=1 or dims=2
  • In-place colwise! and pairwise! variants use preallocated output arrays
  • Weighted versions offered for Euclidean, Cityblock, Minkowski and Hamming distances
Best for: Julia developers and researchers who need a range of distance metrics and efficient column-wise or pairwise distance computations over numeric matrices.
Good for
  • Batch colwise and pairwise functions are described as often substantially faster than straightforward loops
  • Large selection of distance, divergence and dissimilarity measures in one package
  • Functions accept arbitrary iterable objects of known size, not only plain arrays
Watch out for
  • Covers vectors and 2D arrays; distances between tables with heterogeneous columns require the separate TableDistances.jl package
  • Weighted variants are provided only for a subset of metrics, such as Euclidean, squared Euclidean, Cityblock, Minkowski and Hamming

Distances at a glance

Type
Open-source project
Pricing
Not confirmed. Check the site
Open source
Not stated
Language
English
Last checked
Oct 6, 2026 · Online when checked
Listed
Oct 5, 2026

Distances alternatives

Tools and sites you could use instead, ranked by how closely they match.

All 24 alternatives

Popular in Developer Tools

Well-known listings from the same topic.

All 423

Distances FAQ

What is the difference between colwise and pairwise computation?
colwise computes distances between corresponding columns of two matrices and returns a vector of length n, while pairwise computes distances between every pair of columns and returns an m-by-n matrix.
Can distances be computed when observations are stored in rows?
Yes. Using dims=1 with the pairwise function computes pairwise distances for matrices whose observations are stored in rows; dims=2 is used for column-stored data.
Can results be written without allocating a new array?
Yes. The in-place forms colwise! and pairwise! write results into preallocated vectors or matrices.
Is something wrong or out of date?

Tell us and an editor will check it.

Own this website?

Claim the listing and suggest updates yourself. An editor checks every claim first.

Claim this listing