-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Labels
Description
This was actually never refactored for the new Simulator / V4:
pymc/pymc/distributions/simulator.py
Lines 276 to 293 in c76b9b9
| class KullbackLiebler: | |
| """Approximate Kullback-Liebler.""" | |
| def __init__(self, obs_data): | |
| if obs_data.ndim == 1: | |
| obs_data = obs_data[:, None] | |
| n, d = obs_data.shape | |
| rho_d, _ = cKDTree(obs_data).query(obs_data, 2) | |
| self.rho_d = rho_d[:, 1] | |
| self.d_n = d / n | |
| self.log_r = np.log(n / (n - 1)) | |
| self.obs_data = obs_data | |
| def __call__(self, epsilon, obs_data, sim_data): | |
| if sim_data.ndim == 1: | |
| sim_data = sim_data[:, None] | |
| nu_d, _ = cKDTree(sim_data).query(self.obs_data, 1) | |
| return self.d_n * np.sum(-np.log(nu_d / self.rho_d) / epsilon) + self.log_r |