naginterfaces.library.tsa.kalman_unscented_state¶
- naginterfaces.library.tsa.kalman_unscented_state(y, lx, ly, f, h, x, st, data=None, spiked_sorder='C')[source]¶
kalman_unscented_state
applies the Unscented Kalman Filter (UKF) to a nonlinear state space model, with additive noise.kalman_unscented_state
uses direct communication for evaluating the nonlinear functionals of the state space model.For full information please refer to the NAG Library document for g13ek
https://www.nag.com/numeric/nl/nagdoc_27.3/flhtml/g13/g13ekf.html
- Parameters
- yfloat, array-like, shape
, the observed data at the current time point.
- lxfloat, array-like, shape
, such that , i.e., the lower triangular part of a Cholesky decomposition of the process noise covariance structure. Only the lower triangular part of is referenced.
If is time dependent, the value supplied should be for time .
- lyfloat, array-like, shape
, such that , i.e., the lower triangular part of a Cholesky decomposition of the observation noise covariance structure. Only the lower triangular part of is referenced.
If is time dependent, the value supplied should be for time .
- fcallable fxt = f(xt, data=None)
The state function, .
- Parameters
- xtfloat, ndarray, shape
, the sigma points generated in (a). For the th sigma point, the value for the th parameter is held in , for , for .
- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- Returns
- fxtfloat, array-like, shape
.
For the th sigma point the value for the th parameter should be held in , for , for .
- hcallable hyt = h(my, yt, data=None)
The measurement function, as described in (e).
- Parameters
- myint
, the number of observed variables.
- ytfloat, ndarray, shape
, the sigma points generated in (d). For the th sigma point, the value for the th parameter is held in , for , for , where is the number of state variables and is the number of sigma points.
- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- Returns
- hytfloat, array-like, shape
.
For the th sigma point the value for the th parameter should be held in , for , for .
- xfloat, array-like, shape
the state vector for the previous time point.
- stfloat, array-like, shape
, such that , i.e., the lower triangular part of a Cholesky decomposition of the state covariance matrix at the previous time point. Only the lower triangular part of is referenced.
- dataarbitrary, optional
User-communication data for callback functions.
- spiked_sorderstr, optional
If and are spiked (i.e., have unit extent in all but one dimension, or have size ), selects the storage order to associate with them in the NAG Engine:
- spiked_sorder =
row-major storage will be used;
- spiked_sorder =
column-major storage will be used.
Two-dimensional arrays returned from callback functions in this routine must then use the same storage order.
- Returns
- xfloat, ndarray, shape
the updated state vector.
- stfloat, ndarray, shape
, the lower triangular part of a Cholesky factorization of the updated state covariance matrix.
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
A weight was negative and it was not possible to downdate the Cholesky factorization.
- (errno )
Unable to calculate the Kalman gain matrix.
- (errno )
Unable to calculate the Cholesky factorization of the updated state covariance matrix.
- Warns
- NagCallbackTerminateWarning
- (errno )
User requested termination in .
- (errno )
User requested termination in .
- Notes
kalman_unscented_state
applies the Unscented Kalman Filter (UKF), as described in Julier and Uhlmann (1997b) to a nonlinear state space model, with additive noise, which, at time , can be described by:where represents the unobserved state vector of length and the observed measurement vector of length . The process noise is denoted , which is assumed to have mean zero and covariance structure , and the measurement noise by , which is assumed to have mean zero and covariance structure .
Unscented Kalman Filter Algorithm
Given , an initial estimate of the state and and initial estimate of the state covariance matrix, the UKF can be described as follows:
Generate a set of sigma points (see Sigma Points):
Evaluate the known model function :
The function is assumed to accept the matrix, and return an matrix, . The columns of both and correspond to different possible states. The notation is used to denote the th column of , hence the result of applying to the th possible state.
Time Update:
Redraw another set of sigma points (see Sigma Points):
Evaluate the known model function :
The function is assumed to accept the matrix, and return an matrix, . The columns of both and correspond to different possible states. As above is used to denote the th column of .
Measurement Update:
Here is the Kalman gain matrix, is the estimated state vector at time and the corresponding covariance matrix. Rather than implementing the standard UKF as stated above
kalman_unscented_state
uses the square-root form described in the Haykin (2001).Sigma Points
A nonlinear state space model involves propagating a vector of random variables through a nonlinear system and we are interested in what happens to the mean and covariance matrix of those variables. Rather than trying to directly propagate the mean and covariance matrix, the UKF uses a set of carefully chosen sample points, referred to as sigma points, and propagates these through the system of interest. An estimate of the propagated mean and covariance matrix is then obtained via the weighted sample mean and covariance matrix.
For a vector of random variables, , with mean and covariance matrix , the sigma points are usually constructed as:
When calculating the weighted sample mean and covariance matrix two sets of weights are required, one used when calculating the weighted sample mean, denoted and one used when calculating the weighted sample covariance matrix, denoted . The weights and multiplier, , are constructed as follows:
where, usually and and are constants. The total number of sigma points, , is given by . The constant is usually set to somewhere in the range and for a Gaussian distribution, the optimal values of and are and respectively.
The constants, , and are given by , and . If more control is required over the construction of the sigma points then the reverse communication function,
kalman_unscented_state_revcom()
, can be used instead.
- References
Haykin, S, 2001, Kalman Filtering and Neural Networks, John Wiley and Sons
Julier, S J, 2002, The scaled unscented transformation, Proceedings of the 2002 American Control Conference (Volume 6), 4555–4559
Julier, S J and Uhlmann, J K, 1997, A consistent, debiased method for converting between polar and Cartesian coordinate systems, Proceedings of AeroSense ‘97, International Society for Optics and Phonotonics, 110–121
Julier, S J and Uhlmann, J K, 1997, A new extension of the Kalman Filter to nonlinear systems, International Symposium for Aerospace/Defense, Sensing, Simulation and Controls (Volume 3) (26)