studykde.py 文件源码

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

项目:bayestsa 作者: thalesians 项目源码 文件源码
def __call__(self, params):
        print '???', params
        sd1 = params[0]
        sd2 = params[1]
        cor = params[2]

        if sd1 < 0. or sd1 > 10. or sd2 < 0. or sd2 > 10. or cor < -1. or cor > 1.:
            return np.inf

        bandwidth = maths.stats.choleskysqrt2d(sd1, sd2, cor)
        bandwidthdet = la.det(bandwidth)
        bandwidthinv = la.inv(bandwidth)

        diff = sample[self.__iidx] - sample[self.__jidx]
        temp = diff.dot(bandwidthinv.T)
        temp *= temp
        e = np.exp(np.sum(temp, axis=1))
        s = np.sum(e**(-.25) - 4 * e**(-.5))

        cost = self.__n / bandwidthdet + (2. / bandwidthdet) * s
        print '!!!', cost
        return cost / 10000.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号