Here's another clustering algorithm for data points in the stats table. Like K Means it doesn't read data from the frequency column so multiplicities have to be types in multiple rows instead of using the Freq column. The freq column will contain the number of the cluster that each point is assigned at the end.

The distance function used is the euclidean distance of the centers of the clusters so this is a bad (but fast) hierarchical clustering algorithm.

In the future I will probably update it to support single-linkage distance but it will be REALLY slow.

FreqOff n→T FreqOn 0→DimZ 3T+3→DimZ For 1→I To T List X[I]→Z[3I] List Y[I]→Z[3I+1] 1→Z[3I+2] I→List Freq[I] Next "CLUSTERS"?C For T→A To C+1 Step -1 10×10^99→B For 1→I To A-1 For I+1→J To A √((Z[3I]-Z[3J])²+(Z[3I+1]-Z[3J+1])²)→D If D<B:Then D→B I→V J→W IfEnd Next Next List Freq[W]→List Freq[V] (Z[3V]×Z[3V+2]+Z[3W]×Z[3W+2])÷(Z[3V+2]+Z[3W+2])→Z[3V] (Z[3V+1]×Z[3V+2]+Z[3W+1]×Z[3W+2])÷(Z[3V+2]+Z[3W+2])→Z[3V+1] Z[3V+2]+Z[3W+2]→Z[3V+2] Z[3A]→Z[3W] Z[3A+1]→Z[3W+1] Z[3A+2]→Z[3W+2] Cls Locate 1,1,"CLUSTERS" Locate 10,1,A-1 Next Cls Locate 1,1,"ASSIGNING" For 1→I To T 10×10^90→B For 1→Q To C √((List X[I]-Z[3Q])²+(List Y[I]-Z[3Q+1])²)→D If D<B:Then D→B Q→W IfEnd Next W→List Freq[I] Next Cls "DONE"