title: Algorithm for identifying non-ambiguous clusters?
body: <p>Clustering algorithms usually take into account that what might be perceived as a reasonable cluster by a human being is ambiguous and the computed solution is supposed to generalize and predict well.</p>
  
  <p>This is why I am hesitant to just use the tried-and-tested algos for my specific situation - which does not mean that I am sure those won't work or might actually be optimal. I just would like to verify that.</p>
  
  <p>So let's look at the following example.</p>
  
  <p><img src="https://i.stack.imgur.com/GRn6Y.png" alt="enter image description here"></p>
  
  <p>Essentially the clusters are obvious and except for exceptions unabmiguous because they are actually linearly separable. The data I refer to is two-dimensional. The clusters follow an unknown distribution with a mode and are independent.</p>
  
  <p>What algorithm performs (speed, robustness, simplicity) well for this specific cluster patterns?</p>
  
  <hr>
  
  <pre><code>rotate &lt;- function(xy, deg, cen) {
    xy &lt;- xy - cen
    return(c(
      xy[1] * cos(deg) - xy[2] * sin(deg), 
      xy[2] * cos(deg) + xy[1] * sin(deg)
    ) + cen)
  }
  
  G &lt;- expand.grid(1:2,1:2)
  
  S &lt;- list()
  N &lt;- 100
  for(i in 1:nrow(G)) {
    set &lt;- data.frame(x = rgamma(N,3,2)*0.2 + G[i,1], y=rgamma(N,3,2)*.1 + G[i,2])
    S[[i]] &lt;- t(apply(set,1,rotate,runif(1,0,pi),c(mean(set[,1]),mean(set[,2]))))
  }
  
  S &lt;- do.call(rbind, S)
  
  plot(S)
  </code></pre>