def gendistribution(xmeanxsdymeanysdnnameprefix)samples [for in range( ) random gauss(xmeanxsdy random gauss(ymeanysdsamples append(example(nameprefix+str( )[xy])return samples def plotsamples(samplesmarker)xvalsyvals [][for in samplesx getfeatures()[ getfeatures()[ pylab annotate( getname()xy (xy)xytext ( + - )fontsize ' -large'xvals append(xyvals append(ypylab plot(xvalsyvalsmarkerdef contrivedtest(numtrialskverbose)random seed( xmean xsd ymean ysd samples gendistribution(xmeanxsdymeanysdn' 'plotsamples( samples' ^' samples gendistribution(xmean+ xsdymean+ ysdn' 'plotsamples( samples'ro'clusters trykmeans( samples samplesexampleknumtrialsverboseprint 'final resultfor in clustersprint '' figure test of -means when executedthe call contrivedtest( trueproduced the plot in figure figure examples from two distributions