Cluster a Bivariate Dataset
data = ExampleData[{"Statistics", "OldFaithful"}];
𝒟 = KernelMixtureDistribution[data, "StandardGaussian"];rng = RandomVariate[𝒟, 500];Use FindClusters to split the data:
Show[SmoothDensityHistogram[rng, ColorFunction -> "TemperatureMap", Mesh -> Automatic], ListPlot[FindClusters[rng, 2], PlotRange -> {{1, 6}, {30, 110}}, PlotStyle -> {Black, Red}]]Show[
SmoothHistogram3D[rng,
PlotStyle -> Opacity[0.5], PlotLabel -> Text[Style["Duration vs. Waiting Time", FontFamily -> "Helvetica"]], MeshStyle -> Opacity[.3], ColorFunction -> "TemperatureMap", Boxed -> False, ViewPoint -> {2, -2, 1}, ImageSize -> Medium],
Graphics3D[
MapThread[
{#2, Point[Table[Append[pt, 0], {pt, #1}]]}&, {FindClusters[rng, 2], {Black, Red}}
]
]
]