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])
评论列表
文章目录