trj [:, (np random randn ( , )sigma [ ]mu[ ]reshape ( , np zeros (nfor in range ( , ) [ifunc(trj[ ]sortedids np argsort (sfrom smallest to largest s_sorted ssortedids best_trj np array (nbest_perf np inf eliteids sortedids range ( nel)elitetrj trj[eliteids ,:mu np mean(elitetrj ,axis = sigma np std(elitetrj ,axis = if(best_perf s_sorted [ ])best_perf s_sorted [ best_trj trjsortedids [ ]print best_perf print best_trj reshape ( , ) [- - - - ] hierarchical clustering it is sometimes useful to determine data clusters in hierarchical manneran example is the construction of evolutionary relationships between animal species establishing hierarchy of clusters can be done in bottom-up or top-down manner in the bottom-up approachalso called agglomerative clusteringthe data points are merged in larger and larger clusters until all the points have been merged into single cluster in the top-down or divisive clustering approachthe data set is divided up into smaller and smaller clusters the left panel of figure depicts hierarchy of clusters in figure each cluster is given cluster identifier at the lowest level are clusters comprised of the original data points (identifiers the union of clusters and form cluster with identifier and the union of and form cluster with identifier in turn the union of clusters and constitutes cluster and so on the right panel of figure shows convenient way to visualize cluster hierarchies using dendrogram (from the greek dendro for treea dendrogram not only summarizes how clusters are merged or splitbut also shows the distance between clustershere on the vertical axis the horizontal axis shows which cluster each data point (labelbelongs to many different types of hierarchical clustering can be performeddepending on how the distance is defined between two data points and between two clusters denote the data set by {xi nas in section let dist(xi be the distance between data points xi and the default choice is the euclidean distance dist(xi kxi let and be two disjoint subsets of { nthese sets correspond to two disjoint subsets (that isclustersof {xi iand { jwe denote the distance between agglomerative clustering divisive clustering dendrogram