def calculate_error(self, correct_states, error_norms=(2, 4, 8)): """Generate error matrices. First dimension: Index of the tracked object Second dimension: P in the L^P norm: 2, 4, 8 Third dimension: Time step """ self.absolute_error = [] self.relative_error = [] for track, correct in izip(self.tracks, correct_states): distances = [] relative_errors = [] for P in error_norms: distances_P = numpy.array(wmath.spline_lp_distances(track, correct, self.renderer_length, P)) correct_norms_P = numpy.array(wmath.spline_lp_norms(correct, self.renderer_length, P)) relative_errors_P = distances_P / correct_norms_P distances.append(distances_P) relative_errors.append(relative_errors_P) self.absolute_error.append(numpy.array(distances)) self.relative_error.append(numpy.array(relative_errors)) self.absolute_error = numpy.array(self.absolute_error) self.relative_error = numpy.array(self.relative_error)
def weight_function(self, prev_particle, from_states): return (1.0/(wmath.spline_lp_distances(prev_particle, from_states, self.renderer_length, self.lp_space)))**self.weight_power