Created
July 11, 2018 22:55
-
-
Save maxentile/d75b94bfa307af9ba0f09c8732b7575a to your computer and use it in GitHub Desktop.
MBAR's computePerturbedFreeEnergies doesn't play nice with autograd. This does.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from autograd.scipy.misc import logsumexp | |
from autograd import grad | |
from autograd import numpy as np | |
import pymbar | |
def compute_perturbed_free_energies(mbar, u_ln): | |
states_with_samples = (mbar.N_k > 0) | |
log_q_k = mbar.f_k[states_with_samples] - mbar.u_kn[states_with_samples].T | |
log_denominator_n = logsumexp(log_q_k, b=mbar.N_k[states_with_samples], axis=1) | |
return logsumexp(-u_ln[:len(u_ln)] - log_denominator_n, axis=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment