but for the probability distribution { (ti ( )becomes degenerateputting all its probability mass on argmink kxi uk this corresponds to the -means rule of assigning xi to its nearest cluster center moreoverin the -step ( each cluster center (tk is now updated according to the average of the {xi that have been assigned to cluster we thus obtain the same deterministic updating rule as in -means example ( -means clusteringwe cluster the data from figure via -meansusing the python implementation below note that the data points are stored as matrix xmat we take the same starting centers as in the em examplec [- - ] [- ]and [ - ]note also that squared euclidean distances are used in the computationsas these are slightly faster to compute than euclidean distances (as no square root computations are requiredwhile yielding exactly the same cluster center evaluations kmeans py import numpy as np xmat np genfromtxt ('clusterdata csv 'delimiter =',' nd xmat shape np array ([- - , ,- , - ]]initialize centers cold np zeros ( shape dist np zeros (( , )while np abs( coldsum ( cold copy (for in range ( , )compute the squared distances dist [ ,:np sum (xmat [:,it)** label np argmin (dist , assign the points to nearest centroid minvals np amin(dist , for in range ( , )recompute the centroids [:,inp mean(xmat[np where label = ,:, reshape ( , print ('loss {: }format minvals mean ())loss - - - - - - - - figure results of the -means algorithm applied to the data in figure the thick black circles are the centroids and the dotted lines define the cell boundaries