astrom_common.py 文件源码

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

项目:astromalign 作者: dstndstn 项目源码 文件源码
def mahalanobis_distsq(X, mu, C):
    #print 'X', X.shape
    #print 'mu', mu.shape
    #print 'C', C.shape
    assert(C.shape == (2,2))
    det = C[0,0]*C[1,1] - C[0,1]*C[1,0]
    Cinv = np.array([[ C[1,1]/det, -C[0,1]/det],
             [-C[1,0]/det,  C[0,0]/det]])
    #print 'Cinv', Cinv.shape
    #print 'Cinv * C:', np.dot(Cinv, C)
    #print 'C * Cinv:', np.dot(C, Cinv)
    d = X - mu
    #print 'd', d.shape
    Cinvd = np.dot(Cinv, d.T)
    #print 'Cinvd', Cinvd.shape
    M = np.sum(d * Cinvd.T, axis=1)
    #print 'M', M.shape
    return M
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号