msmle.py 文件源码

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

项目:pynamd 作者: radakb 项目源码 文件源码
def compute_unsampled_weights(self, u_jn):
        """Compute the sample weights for unsampled states. This requires the
        observed reduced potential energies on the complete sample set.

        NB Use of this function can be obviated by simply including the
        unsampled states in the initial calculation. 

        Arguments
        ---------
        u_jn : array-like
            2d array-like of reduced potential energies. The dimensions must
            be L x N, where L is the number of states to compute free energies
            for and N is the total sample size.

        Returns
        -------
        W_nj_k : ndarray
            Sample weights for the N samples in each of L states 
        """
        u_nj_k = asarray(u_jn).T
        # NB ESTIMATING ERRORS HERE WILL CAUSE AN INFINITE LOOP!
        f_k, varf_k = self.compute_unsampled_free_energies(u_jn, False)
        logQ_nj_k = f_k[newaxis, :] - u_nj_k
        m = self.nstates_sampled
        logQ_nj = self._f[newaxis, :] - self._u_nj
        logNorm_n = logsumexp(logQ_nj[:, :m], 1, self.PIsdiag[newaxis, :])
        return exp(logQ_nj_k - logNorm_n[:, newaxis])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号