def testKalmanTransition(self): prev_mean = np.asarray([[-2], [.4]], dtype=np.float32) prev_cov = np.asarray([[.5, -.2], [-.2, .9]], dtype=np.float32) prev_mean_tensor = self.build_tensor(prev_mean) prev_cov_tensor = self.build_tensor(prev_cov) predicted_mean, predicted_cov = kalman_transition( prev_mean_tensor, prev_cov_tensor, self.get_transition_matrix_for_timestep(0), self.get_transition_noise_for_timestep(0)) self.assertAllClose(self.evaluate(predicted_mean), np.dot(self.transition_matrix, prev_mean) + self.bias[:, np.newaxis]) self.assertAllClose(self.evaluate(predicted_cov), np.dot(self.transition_matrix, np.dot(prev_cov, self.transition_matrix.T)) + np.eye(2))
def testKalmanTransition(self): prev_mean = np.asarray([[-2], [.4]], dtype=np.float32) prev_cov = np.asarray([[.5, -.2], [-.2, .9]], dtype=np.float32) prev_mean_tensor = self.build_tensor(prev_mean) prev_cov_tensor = self.build_tensor(prev_cov) predicted_mean, predicted_cov = kalman_transition( prev_mean_tensor, prev_cov_tensor, self.get_transition_matrix_for_timestep(0), self.get_transition_noise_for_timestep(0)) self.assertAllClose(self.evaluate(predicted_mean), np.dot(self.transition_matrix, prev_mean) + self.bias[:, np.newaxis]) self.assertAllClose(self.evaluate(predicted_cov), np.dot(self.transition_matrix, np.dot(prev_cov, self.transition_matrix.T)) + np.eye(2))