Cluster Analysis

The following graphics show the clustering of data with different distance functions and numbers of cluster sets. Note that the same FindClusters function was used in all cases.

Different Cluster Sizes

ClusterPlot[FindClusters[data], Frame -> True]

ClusterPlot[FindClusters[data, 4], Frame -> True]

ClusterPlot[FindClusters[data, 6], Frame -> True]

ClusterPlot[FindClusters[data, 8], Frame -> True]

Different Distance Functions

ClusterPlot[FindClusters[data, DistanceFunction -> Automatic], 
      Frame -> True]

ClusterPlot[
      FindClusters[data, DistanceFunction -> ManhattanDistance], 
      Frame -> True]

ClusterPlot[FindClusters[data, DistanceFunction -> SupDistance], 
      Frame -> True]

ClusterPlot[
      FindClusters[data, DistanceFunction -> BrayCurtisDistance], 
      Frame -> True]

ClusterPlot[
      FindClusters[data, DistanceFunction -> CanberraDistance], 
      Frame -> True]

Initialization

Needs["Statistics`ClusterAnalysis`"]

Needs["Statistics`ContinuousDistributions`"]

Needs["Statistics`MultiDescriptiveStatistics`"]

GaussianRandomData[n_Integer, p_, sigma_] := 
      Table[p + {Re[#], Im[#]} &[
          Random[NormalDistribution[0, 
                sigma]] (E^(I Random[Real, {0, 2  π}]))], {n}]

SeedRandom[4985347998];

With[{n  =  100}, 
data = 
          Join[GaussianRandomData[n, {2, 1},  .4], 
            GaussianRandomData[n, {1, 1.5},  .5], 
            GaussianRandomData[n, {1, 1},  .3]]];

ClusterPlot[cl_, opts___] := 
      Module[{len, colors}, 
len = 
          Length[cl]; 
colors = 
          PadRight[{Red, Blue, Green, Purple, Black, Orange, Yellow, Brown}, 
            len, {Red, Blue, Green, Purple, Black, Orange, Yellow, 
              Brown}]; 
Show[
          Graphics[{AbsolutePointSize[5], 
              Transpose[{colors, Map[Thread[Point /@ #] &, cl]}]}, 
            opts]]
]