naginterfaces.library.tsa.kalman_unscented_state_revcom¶
- naginterfaces.library.tsa.kalman_unscented_state_revcom(irevcm, y, ly, x, st, xt, fxt, comm, lx=None, ropt=None)[source]¶
kalman_unscented_state_revcom
applies the Unscented Kalman Filter to a nonlinear state space model, with additive noise.kalman_unscented_state_revcom
uses reverse communication for evaluating the nonlinear functionals of the state space model.For full information please refer to the NAG Library document for g13ej
https://www.nag.com/numeric/nl/nagdoc_29/flhtml/g13/g13ejf.html
- Parameters
- irevcmint
On initial entry: must be set to or .
If , it is assumed that , otherwise it is assumed that and that
kalman_unscented_state_revcom
has been called at least once before at an earlier time step.On intermediate entry: must remain unchanged.
- yfloat, array-like, shape
, the observed data at the current time point.
- 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 .
- xfloat, ndarray, shape , modified in place
On initial entry: the state vector for the previous time point.
On intermediate exit: when
is unchanged.
.
On intermediate entry: must remain unchanged.
On final exit: the updated state vector.
- stfloat, ndarray, shape , modified in place
On initial entry: , 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.
On intermediate exit: when
is unchanged.
, the lower triangular part of a Cholesky factorization of .
On intermediate entry: must remain unchanged.
On final exit: , the lower triangular part of a Cholesky factorization of the updated state covariance matrix.
- xtfloat, ndarray, shape , modified in place
Note: the required extent for this argument in dimension 2 is determined as follows: if : ; if : ; otherwise: .
On initial entry: need not be set.
On intermediate exit: when , otherwise .
For the th sigma point, the value for the th parameter is held in , for , for .
On intermediate entry: must remain unchanged.
On final exit: the contents of are undefined.
- fxtfloat, ndarray, shape , modified in place
Note: the required extent for this argument in dimension 1 is determined as follows: if : ; otherwise: .
Note: the required extent for this argument in dimension 2 is determined as follows: if : ; if : ; otherwise: .
On initial entry: need not be set.
On intermediate exit: the contents of are undefined.
On intermediate entry: when , otherwise for the values of and held in .
For the th sigma point the value for the th parameter should be held in , for .
When , and when , .
On final exit: the contents of are undefined.
- commdict, communication object, modified in place
Communication structure.
On initial entry: need not be set.
- lxNone or float, array-like, shape , optional
, 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 , there is no process noise ( for all ) and is not referenced.
If is time dependent, the value supplied should be for time .
- roptNone or float, array-like, shape , optional
Options. The default value will be used for if . Setting will use the default values for all options and need not be set.
If set to then the second set of sigma points are redrawn, as given by equation [equation]. If set to then the second set of sigma points are generated via augmentation, as given by equation [equation].
Default is for the sigma points to be redrawn (i.e., )
, value of used when constructing the first set of sigma points, .
Defaults to .
, value of used when constructing the first set of sigma points, .
Defaults to .
, value of used when constructing the first set of sigma points, .
Defaults to .
Value of used when constructing the second set of sigma points, .
Defaults to when and the second set of sigma points are augmented and otherwise.
Value of used when constructing the second set of sigma points, .
Defaults to .
Value of used when constructing the second set of sigma points, .
Defaults to .
- Returns
- irevcmint
On intermediate exit: or . The value of specifies what intermediate values are returned by this function and what values the calling program must assign to arguments of
kalman_unscented_state_revcom
before re-entering the routine. Details of the output and required input are given in the individual argument descriptions.On final exit:
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: , , or .
- (errno )
On entry, .
Constraint: .
- (errno )
has changed between calls.
On intermediate entry, .
On initial entry, .
- (errno )
On entry, .
Constraint: .
- (errno )
has changed between calls.
On intermediate entry, .
On initial entry, .
- (errno )
On entry, augmented sigma points requested, and .
Constraint: .
- (errno )
On entry, redrawn sigma points requested, and .
Constraint: .
- (errno )
has changed between calls.
On intermediate entry, .
On intermediate exit, .
- (errno )
On entry, .
Constraint: or .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
[‘icomm’] has been corrupted between calls.
- (errno )
[‘rcomm’] has been corrupted between calls.
- (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
- NagAlgorithmicWarning
- (errno )
On entry, and .
Constraint: and .
The minimum required values for and are returned in and respectively.
- Notes
kalman_unscented_state_revcom
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_revcom
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.
Rather than redrawing another set of sigma points in (d) of the UKF an alternative method can be used where the sigma points used in (a) are augmented to take into account the process noise. This involves replacing equation [equation] with:
Augmenting the sigma points in this manner requires setting to (and hence to ) and recalculating the weights. These new values are then used for the rest of the algorithm. The advantage of augmenting the sigma points is that it keeps any odd-moments information captured by the original propagated sigma points, at the cost of using a larger number of points.
- 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)