# 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 Options

• DistanceMatrix works for a variety of data, including numerical, geospatial, textual, visual, dates and times, as well as combinations of these.
• Each ui can be a single data element, a list of data elements or an association of data elements. In DistanceMatrix[data,], data can also be a Dataset object.
• The following options can be given:
•  DistanceFunction Automatic the distance metric to use FeatureExtractor Identity how to preprocess data FeatureNames Automatic feature names to assign for data FeatureTypes Automatic feature types to assume for data 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 text and nominal sequences Abs[DateDifference[#1,#2]]& dates and times ColorDistance colors GeoDistance geospatial data Boole[SameQ[#1,#2]]& nominal data HammingDistance nominal vector data WarpingDistance numerical sequences
• All images are first conformed using ConformImages.
• By default, when data elements are mixed-type vectors, distances are computed independently for each type and combined using Norm.
• Possible settings for PerformanceGoal include:
•  "Speed" minimize computation time "Quality" maximize precision and accuracy Automatic automatic tradeoff between speed and precision

# Examples

open allclose all

## 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=