# unscented_transform¶

Copyright 2015 Roger R Labbe Jr.

FilterPy library. http://github.com/rlabbe/filterpy

Supporting book at: https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python

filterpy.kalman.unscented_transform(sigmas, Wm, Wc, noise_cov=None, mean_fn=None, residual_fn=None)[source]
Parameters: sigmas: ndarray, of size (n, 2n+1) 2D array of sigma points. Wm : ndarray [# sigmas per dimension] Weights for the mean. Wc : ndarray [# sigmas per dimension] Weights for the covariance. noise_cov : ndarray, optional noise matrix added to the final computed covariance matrix. mean_fn : callable (sigma_points, weights), optional Function that computes the mean of the provided sigma points and weights. Use this if your state variable contains nonlinear values such as angles which cannot be summed. def state_mean(sigmas, Wm): x = np.zeros(3) sum_sin, sum_cos = 0., 0. for i in range(len(sigmas)): s = sigmas[i] x += s * Wm[i] x += s * Wm[i] sum_sin += sin(s)*Wm[i] sum_cos += cos(s)*Wm[i] x = atan2(sum_sin, sum_cos) return x  residual_fn : callable (x, y), optional Function that computes the residual (difference) between x and y. You will have to supply this if your state variable cannot support subtraction, such as angles (359-1 degreees is 2, not 358). x and y are state vectors, not scalars. def residual(a, b): y = a - b y = y % (2 * np.pi) if y > np.pi: y -= 2*np.pi return y  x : ndarray [dimension] Mean of the sigma points after passing through the transform. P : ndarray covariance of the sigma points after passing throgh the transform.