def _covar_mstep_tied(gmm, X, responsibilities, weighted_X_sum, norm, min_covar):
 avg_X2 = np.dot(X.T, X)
 avg_means2 = np.dot(gmm.means_.T, weighted_X_sum)
 out = (avg_X2 - avg_means2)
 out *= (1.0 / X.shape[0])
 out.flat[::(len(out) + 1)] += min_covar
 return out

def _covar_mstep_tied ( gmm , X , responsibilities , weighted_X_sum , norm , min_covar ) : avg_X2 = np . dot ( X . T , X ) avg_means2 = np . dot ( gmm . means_ . T , weighted_X_sum ) out = ( avg_X2 - avg_means2 ) out *= ( 1.0 / X . shape [ 0 ] ) out . flat [ : : ( len ( out ) + 1 ) ] += min_covar return out
perform the covariance m step for tied cases .