mirror of
https://github.com/AtsushiSakai/PythonRobotics.git
synced 2026-01-12 20:48:01 -05:00
imporve nomalize weight function
This commit is contained in:
@@ -60,15 +60,15 @@ def normalize_weight(particles):
|
||||
|
||||
sumw = sum([p.w for p in particles])
|
||||
|
||||
if sumw <= 0.0000001:
|
||||
try:
|
||||
for i in range(N_PARTICLE):
|
||||
particles[i].w /= sumw
|
||||
except ZeroDivisionError:
|
||||
for i in range(N_PARTICLE):
|
||||
particles[i].w = 1.0 / N_PARTICLE
|
||||
|
||||
return particles
|
||||
|
||||
for i in range(N_PARTICLE):
|
||||
particles[i].w /= sumw
|
||||
|
||||
return particles
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user