change resampling calculation to match with the book

This commit is contained in:
Göktuğ Karakaşlı
2019-10-23 21:46:33 +03:00
parent 692b7bd684
commit 9f4102378a

View File

@@ -141,9 +141,8 @@ def re_sampling(px, pw):
N_eff = 1.0 / (pw.dot(pw.T))[0, 0] # Effective particle number
if N_eff < NTh:
w_cum = np.cumsum(pw)
base = np.cumsum(pw * 0.0 + 1 / NP) - 1 / NP
re_sample_id = base + np.random.rand(base.shape[0]) / NP
base = np.arange(0.0, 1.0, 1/NP)
re_sample_id = base + np.random.uniform(0, 1/NP)
indexes = []
ind = 0
for ip in range(NP):