From 8c9ebd4bf07ce21c7867a902565924af362b887e Mon Sep 17 00:00:00 2001 From: LiftingBanana Date: Tue, 4 Sep 2018 11:22:02 +0200 Subject: [PATCH 1/2] Prob. a bug as mu is not ordered; mask should apply to the kernel locs --- src/qinfer/resamplers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qinfer/resamplers.py b/src/qinfer/resamplers.py index 80531fd..a2af5a7 100644 --- a/src/qinfer/resamplers.py +++ b/src/qinfer/resamplers.py @@ -369,7 +369,7 @@ def __call__(self, model, particle_dist, # This may look a little weird, but it should delete the unused # elements of js, so that we don't need to reallocate. js = js[np.logical_not(valid_mask)] - mus = mus[:idxs_to_resample.size, :] + mus = mus[idxs_to_resample, :] if idxs_to_resample.size: # We failed to force all models to be valid within maxiter attempts. From 7fc8260828d6f214dab8461c07c83dc9cdee664b Mon Sep 17 00:00:00 2001 From: LiftingBanana Date: Fri, 14 Sep 2018 13:31:03 +0200 Subject: [PATCH 2/2] Fixed resampling locations --- src/qinfer/resamplers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qinfer/resamplers.py b/src/qinfer/resamplers.py index a2af5a7..2ddc464 100644 --- a/src/qinfer/resamplers.py +++ b/src/qinfer/resamplers.py @@ -329,7 +329,8 @@ def __call__(self, model, particle_dist, n_iters += 1 # Draw x_i from N(mu_i, S). - new_locs[idxs_to_resample, :] = mus + np.dot(S, self._kernel(n_rvs, mus.shape[0])).T + mus_temp = mus[idxs_to_resample, :] + new_locs[idxs_to_resample, :] = mus_temp + np.dot(S, self._kernel(n_rvs, mus_temp.shape[0])).T # Now we remove from the list any valid models. # We write it out in a longer form than is strictly necessary so @@ -369,7 +370,7 @@ def __call__(self, model, particle_dist, # This may look a little weird, but it should delete the unused # elements of js, so that we don't need to reallocate. js = js[np.logical_not(valid_mask)] - mus = mus[idxs_to_resample, :] + if idxs_to_resample.size: # We failed to force all models to be valid within maxiter attempts.