I wrote a [k-Means clustering](http://en.wikipedia.org/wiki/K-means_clustering) algorithm in MATLAB, and I thought I'd try it against MATLABs built in `kmeans(X,k)`.

However, for the very easy four cluster setup (see picture), MATLAB [kMeans](http://www.mathworks.com/help/toolbox/stats/kmeans.html) does not always converge to the optimum solution (left) but to (right).

The one I wrote does not always do that either, but should not the built-in function be able to solve such an easy problem, always finding the optimal solution?

![alt text](https://i.stack.imgur.com/DYv31.png)