({{, (RefLink[DistanceFunction, paclet:ref/DistanceFunction]) 
is an option for functions such as (RefLink[Nearest, paclet:ref/Nearest]) that specifies the distance value to assume between any two specified points.}})

OpenersNotesSection(Spacer1)Details

(RefLink[DistanceFunction, paclet:ref/DistanceFunction])->f specifies that the distance assumed between x and y should be f[x,y].

OpenersPrimaryExamplesSection(Spacer1)Examples  (2)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Find points closest to {5,5} using (RefLink[ChessboardDistance, paclet:ref/ChessboardDistance]):

Nearest[{{5,9},{2,4},{3,8},{0,8},{5,2}},{5,5},DistanceFunction->ChessboardDistance]

Use the default distance:

Nearest[{{5,9},{2,4},{3,8},{0,8},{5,2}},{5,5}]

Find clusters in Boolean data using (RefLink[DiceDissimilarity, paclet:ref/DiceDissimilarity]):

data={{1, 0},{0,1},{0,0},{1,1},{1,1},{1,0},{0,1}, {0,1}};

FindClusters[data, DistanceFunction->DiceDissimilarity]

Clusters obtained with the default distance function:

FindClusters[data]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[DistanceMatrix, paclet:ref/DistanceMatrix])  ▪  (RefLink[Norm, paclet:ref/Norm])  ▪  (RefLink[NormFunction, paclet:ref/NormFunction])  ▪  (RefLink[EuclideanDistance, paclet:ref/EuclideanDistance])  ▪  (RefLink[EditDistance, paclet:ref/EditDistance])  ▪  (RefLink[JaccardDissimilarity, paclet:ref/JaccardDissimilarity])  ▪  (RefLink[SimilarityRules, paclet:ref/SimilarityRules])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Using Nearest, paclet:tutorial/UsingNearest])}, {▪(RefLinkPlain[Partitioning Data into Clusters, paclet:tutorial/PartitioningDataIntoClusters])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Distance and Similarity Measures, paclet:guide/DistanceAndSimilarityMeasures])}, {▪(RefLinkPlain[Cluster Analysis, paclet:guide/ClusterAnalysis])}})}})