progAss4.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:GMM_using_EM 作者: go2chayan 项目源码 文件源码
def Estep(dataSet,Alpha,Mu,Sigma):
    # We will calculate the membership weight matrix W here. W is an
    # NxK matrix where (i,j)th element represents the probability of
    # ith data point to be a member of jth cluster given the parameters
    # Alpha, Mu and Sigma
    N = np.size(dataSet,0)
    K = np.size(Alpha)
    W = np.zeros([N,K])
    for k in range(K):
        for i in range(N):
            W[i,k] = Alpha[k]*norm_pdf_multivariate(dataSet[i,:][None].T, \
                     Mu[:,k][None].T,Sigma[:,:,k])
    # Normalize W row-wise because each row represents a pdf. In other words,
    # probability of a point to be any one of the K clusters is equal to 1.
    W = W*np.reciprocal(np.sum(W,1)[None].T)
    return W
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号