def Mstep(Y, EZ, EZZT, EX, EXZ, EX2, oldA, old_mus, old_sigmas, old_decay_coef, singleSigma = False):
	assert(len(Y) == len(EZ))
	N, D = Y.shape
	N, K = EZ.shape
	
	#First estimate A and mu
	A = np.zeros([D, K])
	mus = np.zeros([D,1])
	sigmas = np.zeros([D,1])
	Y_is_zero = np.abs(Y) < 1e-6
	#make B, which is the same for all J. 
	B = np.eye(K + 1)
	for k1 in range(K):
		for k2 in range(K):
			B[k1][k2] = sum(EZZT[:, k1, k2])
		B[K, :K] = EZ.sum(axis = 0)
		B[:K, K] = EZ.sum(axis = 0)
	B[K, K] = N
	tiled_EZ = np.tile(np.resize(EZ, [N, 1, K]), [1, D, 1])
	tiled_Y = np.tile(np.resize(Y, [N, D, 1]), [1, 1, K])
	tiled_Y_is_zero = np.tile(np.resize(Y_is_zero, [N, D, 1]), [1, 1, K])
	c = np.zeros([K + 1, D])
	c[K, :] += (Y_is_zero * EX + (1 - Y_is_zero) * Y).sum(axis = 0)
	c[:K, :] = (tiled_Y_is_zero * EXZ + (1 - tiled_Y_is_zero) * tiled_Y * tiled_EZ).sum(axis = 0).transpose()
	solution = np.dot(np.linalg.inv(B), c)
	A = solution[:K, :].transpose()
	mus = np.atleast_2d(solution[K, :]).transpose()

	#then optimize sigma
	EXM = np.zeros([N, D])#have to figure these out  after updating mu. 
	EM = np.zeros([N, D])
	EM2 = np.zeros([N, D])
	
	tiled_mus = np.tile(mus.transpose(), [N, 1])
	tiled_A = np.tile(np.resize(A, [1, D, K]), [N, 1, 1])
	
	EXM = (tiled_A * EXZ).sum(axis = 2) + tiled_mus * EX
	test_sum = (tiled_A * tiled_EZ).sum(axis = 2)
	A_product = np.tile(np.reshape(A, [1, D, K]), [K, 1, 1]) * (np.tile(np.reshape(A, [1, D, K]), [K, 1, 1]).T)
	for i in range(N):
		EM[i, :] = (np.dot(A, EZ[i, :].transpose()) + mus.transpose())#this should be correct
		EZZT_tiled = np.tile(np.reshape(EZZT[i, :, :], [K, 1, K]), [1, D, 1])
		ezzt_sum = (EZZT_tiled * A_product).sum(axis = 2).sum(axis = 0)
		EM2[i, :] = ezzt_sum + 2 * test_sum[i, :]*tiled_mus[i, :] + tiled_mus[i, :] ** 2
	sigmas = (Y_is_zero * (EX2 - 2*EXM + EM2) + (1 - Y_is_zero) * (Y**2 - 2*Y*EM + EM2)).sum(axis = 0)
	sigmas = np.atleast_2d(np.sqrt(sigmas / N)).transpose()
	if singleSigma:
		sigmas = np.mean(sigmas) * np.ones(sigmas.shape)
	decay_coef = minimize(lambda x:decayCoefObjectiveFn(x, Y, EX2), old_decay_coef, jac = True, bounds = [[1e-8, np.inf]])
	decay_coef = decay_coef.x[0]
	return A, mus, sigmas, decay_coef
Gets the SELECT field portion for the field without the alias. If the field
dataset/ETHPy150Open epierson9/ZIFA/ZIFA/ZIFA.py/Mstep--crossover with--dataset/ETHPy150Open ambitioninc/django-query-builder/querybuilder/fields.py/AggregateField.get_select_sql