Em Algorithm, Statistics, Machine Learning, Clustering Algorithm, Python.
range(n_samples): # pick up a cluster_id and generate data from that cluster k = np.random.choice(n_clusters, size=1, p=weights)[0] x = np.random.multivariate_normal(means[k], covariance[k]) data[i] = x labels[i] = k return data, labels # generate sample data sample_means = np.array([ [5,0], [1,1],