crowd_model.py 文件源码

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

项目:code-uai16 作者: thanhan 项目源码 文件源码
def fit_normal(self, a):
        """
        fit a normal distribution to [(x, p)]
        where p is in log scale
        """
        # normalize p:
        #print a
        list_p = []
        for (x, p) in a:  list_p.append(p)
        ps = scipy.misc.logsumexp(list_p)

        s  = 0
        ss = 0
        for (x, p) in a:
            s  += x * np.exp(p - ps)
            ss += x*x * np.exp(p - ps)

        var = ss - s*s
        ep = 1E-300
        if var < ep: var = ep
        return (s, var)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号