# Wolfram Language & System 11.0 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.
BUILT-IN WOLFRAM LANGUAGE SYMBOL

# DistanceMatrix

DistanceMatrix[{u1,u2,}]
gives the matrix of distances between each pair of elements ui, uj.

DistanceMatrix[{u1,u2,},{v1,v2,}]
gives the matrix of distances between each pair of elements ui, vj.

## Details and OptionsDetails and Options

• DistanceMatrix works for a variety of data, including numerical, geospatial, textual, and visual, as well as dates and times.
• The following options can be given:
•  DistanceFunction Automatic the distance metric to use PerformanceGoal Automatic aspects of performance to try to optimize WorkingPrecision Automatic precision to use for numerical data
• The setting for DistanceFunction can be any distance or dissimilarity function or a function f defining a distance between two values.
• By default, the following distance functions are used for different types of elements:
•  EuclideanDistance numeric data ImageDistance images JaccardDissimilarity Boolean data EditDistance strings Abs[DateDifference[#1,#2]]& dates and times ColorDistance colors GeoDistance geospatial data
• All images are first conformed using ConformImages.
• Possible settings for PerformanceGoal include:
•  "Speed" minimize computation time "Quality" maximize precision and accuracy Automatic automatic tradeoff between speed and precision

## ExamplesExamplesopen allclose all

### Basic Examples  (3)Basic Examples  (3)

Compute a distance matrix from a list of integers:

 In[1]:=
 Out[1]=
 In[2]:=
 Out[2]//MatrixForm=

Compute a distance matrix from two lists of integers:

 In[1]:=
 Out[1]=
 In[2]:=
 Out[2]//MatrixForm=

Compute a distance matrix from real-valued numerical vectors:

 In[1]:=
 Out[1]=
 In[2]:=
 Out[2]//MatrixForm=