All problems
Particle Filter Weight Update
Problem
Update particle weights with a likelihood: return the normalized product weights:
w_i_new = w_i * l_i / sum over j of w_j * l_j.
Return an empty list for empty, mismatched or all-zero inputs.
Hint
Multiply then normalize so the weights sum to 1.
Test cases
case 1
in: [[0.5,0.5],[1,2]]
expected: [0.3333333333333333,0.6666666666666666]
case 2
in: [[0.2,0.3,0.5],[0.1,0.2,0.7]]
expected: [0.04651162790697675,0.13953488372093023,0.813953488372093]
case 3
in: [[0.5,0.5],[0,0]]
expected: []
case 4
in: [[1],[3]]
expected: [1]
Starter codePython
def particle_filter_weight_update(weights, likelihoods):
# Your code here
pass4 test cases · run your code against them in the editor