# coding:utf-8 import numpy as np def qq(y,alpha,mu,sigma,K,gama):#计算Q函数 gsum=[] n=len(y) for k in range(K): gsum.append(np.sum([gama[j,k] for j in range(n)])) return np.sum([g*np.log(ak) for g,ak in zip(gsum,alpha)])+\ np.sum([[np.sum(gama[j,k]*(np.…