2
$\begingroup$

Let us consider a 2 dimensional space. There are 100 points in it. So, each point has its $x$ and $y$ coordinates. I want to form 10 clusters. Each cluster has 10 points.

How can I form such clusters.

$\endgroup$
4
  • 1
    $\begingroup$ See FindClusters. $\endgroup$
    – Edmund
    Oct 25, 2018 at 22:18
  • 1
    $\begingroup$ Your "definition" of a cluster needs some clarification. For a start: When are two points in the point cloud "adjacent"? $\endgroup$ Oct 25, 2018 at 22:18
  • 1
    $\begingroup$ @HenrikSchumacher, I have x and y-axis coordinates of 100 points. I want to perform clustring over these points. Lets say I want to generate 10 clusters, each cluster with exactly 10 elements. $\endgroup$
    – MGK
    Oct 26, 2018 at 16:20
  • $\begingroup$ The result is depend by distance of points to cluster center. Consider this situation: cluster 1-points[1-11]-center1, cluster2-ponits[12-20]-center2. there are 11 points in cluster1, 9 points in cluster2, we can move point 11 to cluster2? But distance[center1, point11]< distance[center2, point11], is this valid? $\endgroup$ Oct 28, 2018 at 5:05

2 Answers 2

3
$\begingroup$

You need an exact definition of "adjacent" as Henrik already said, because it is the bread and butter of finding clusters of similar elements.

Otherwise, you can start with

pts = RandomReal[1, {100, 2}];
ListPlot[FindClusters[pts, 10], PlotStyle -> PointSize[0.05]]

Mathematica graphics

$\endgroup$
1
  • 1
    $\begingroup$ Thanks. How do you gurantee that each cluster has 10 points? $\endgroup$
    – MGK
    Oct 26, 2018 at 11:20
2
$\begingroup$

Here an example for constructing two clusters, which can easily expanded to n clusters:

cstart = {1, 2};

Now this forms the "start"-cluster

   clusterStart = (# + cstart) & /@ 
       RandomVariate[NormalDistribution[0, 0.5], {10^3, 2}];

Next a bunch of clusters, somewhat drifting apart from the start cluster

clusterList = 
  Table[(# + cstart + delta*{1, 1}) & /@ 
    RandomVariate[NormalDistribution[0, 0.5], {10^3, 2}], {delta, 0.5,
     4, 0.3}];

Lastly, forming the clusters:

clusterList = {clusterStart, #} & /@ clusterList;

Finally plotting the resulting point sets:

With[{out = 
   Graphics[{{Red, Point[#[[1]]]}, {Green, Point[#[[2]]]}}, 
      Frame -> True] & /@ clusterList},
 GraphicsGrid[Partition[out, 3], ImageSize -> Large]
 ]

this delivers:

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.