def _estimate_gaussian_covariances_diag(resp, X, nk, means, reg_covar):
 avg_X2 = (np.dot(resp.T, (X * X)) / nk[:, np.newaxis])
 avg_means2 = (means ** 2)
 avg_X_means = ((means * np.dot(resp.T, X)) / nk[:, np.newaxis])
 return (((avg_X2 - (2 * avg_X_means)) + avg_means2) + reg_covar)

def _estimate_gaussian_covariances_diag ( resp , X , nk , means , reg_covar ) : avg_X2 = ( np . dot ( resp . T , ( X * X ) ) / nk [ : , np . newaxis ] ) avg_means2 = ( means ** 2 ) avg_X_means = ( ( means * np . dot ( resp . T , X ) ) / nk [ : , np . newaxis ] ) return ( ( ( avg_X2 - ( 2 * avg_X_means ) ) + avg_means2 ) + reg_covar )
estimate the diagonal covariance vectors .