2.2.4.5. sigma_points module¶
Modoule to implement Merwe Sigma Points for an Unscented Kalman Filter with faster computation.
- class sigma_points.MerwePoints(n: int, alpha: float, beta: float, kappa: float, sqrt_method: callable | None = None, subtract: callable | None = None)[source]¶
Bases:
MerweScaledSigmaPoints
Implements faster computation of Merwe Sigma Points for an Unscented Kalman Filter.
Initialize faster Merwe Sigma Points.
Based on
filterpy.kalman.MerweScaledSigmaPoints
.- Parameters:
n (int) – Number of states.
alpha (float) – Determins the spread of the sigma points around the mean. Usually a small positive value (1e-3), according to [3].
beta (float) – Incorporates prior knowledge of the distribution of the mean. For Gaussian x beta=2 is optimal, according to [3].
kappa (float) – Secondary scaling parameter usually set to 0 according to [4], or to 3-n according to [5].
sqrt_method (callable, optional) – square root of a matrix, which has no unique answer. Cholesky is the default choice due to its speed, by default None
subtract (callable, optional) – Function that computes the 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, by default None
- sigma_points(x: float | List[float] | ndarray[Any, dtype[float64]], P: float | List[List[float]] | ndarray[Any, dtype[float64]]) ndarray[Any, dtype[float64]] [source]¶
Compute the sigma points for an unscented Unscented Kalman Filter the mean (x) and covariance(P) of the filter.
Return tuple of the sigma points and weights.
Works with both scalar and array inputs: sigma_points (5, 9, 2) # mean 5, covariance 9 sigma_points ([5, 2], 9*eye(2), 2) # means 5 and 2, covariance 9I
- Parameters:
x (Union[float, List[float], npt.NDArray]) – Mean of state variables, can be scalar if only one state, shape: (n, ) with n equal number of states.
P (Union[float, List[List[float]], npt.NDArray]) – Covariance of the filter. If scalar, is treated as eye(n)*P, shape: (n, n) with n equal number of states.
- Returns:
sigmas – Two dimensional array of sigma points. Each column contains all of the sigmas for one dimension in the problem space.
Ordered by Xi_0, Xi_{1..n}, Xi_{n+1..2n}
- Return type:
npt.NDArray, shape: (n, 2n+1)
- Raises:
ValueError – Number of states of given means does not equal to number of states of initialized Merwe Sigma Points.