nag_kalman_sqrt_filt_info_var (g13ecc) (PDF version)
g13 Chapter Contents
g13 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_kalman_sqrt_filt_info_var (g13ecc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_kalman_sqrt_filt_info_var (g13ecc) performs a combined measurement and time update of one iteration of the time-varying Kalman filter. The method employed for this update is the square root information filter with the system matrices in their original form.

2  Specification

#include <nag.h>
#include <nagg13.h>
void  nag_kalman_sqrt_filt_info_var (Integer n, Integer m, Integer p, Nag_ab_input inp_ab, double t[], Integer tdt, const double ainv[], Integer tda, const double b[], Integer tdb, const double rinv[], Integer tdr, const double c[], Integer tdc, const double qinv[], Integer tdq, double x[], const double rinvy[], const double z[], double tol, NagError *fail)

3  Description

For the state space system defined by
X i+1 = A i X i + B i W i var W i = Q i Y i = C i X i + V i var V i = R i
the estimate of X i  given observations Y 1  to Y i-1  is denoted by X ^ ii - 1  with var X ^ ii - 1 = P ii - 1 = S i SiT . The function performs one recursion of the square root information filter algorithm, summarised as follows:
U 1 Q i - 1 / 2 0 Q i - 1 / 2 w - i S i -1 A i -1 B i S i -1 A i -1 S i -1 X ^ ii 0 R i+1 - 1 / 2 C i+1 R i+1 - 1 / 2 Y i+1 = F i+1 - 1 / 2 * * 0 S i+1 -1 ξ i + 1i + 1 0 0 E i+1 Pre-array Post-array
where U 1  is an orthogonal transformation triangularizing the pre-array. The triangularization is done entirely via Householder transformations exploiting the zero pattern of the pre-array. The term w - i  is the mean process noise and E i+1  is the estimated error at instant i+1 . The inverse of the state covariance matrix P ii  is factored as follows
P ii -1 = S i -1 T S i -1
where P ii = S i SiT  ( S i  is lower triangular).
The new state filtered state estimate is computed via
X ^ i + 1i + 1 = S i+1 ξ i + 1i + 1
The function returns S i+1 -1  and X ^ i + 1i + 1  (see the g13 Chapter Introduction for more information concerning the information filter).

4  References

Anderson B D O and Moore J B (1979) Optimal Filtering Prentice–Hall
Vanbegin M, van Dooren P and Verhaegen M H G (1989) Algorithm 675: FORTRAN subroutines for computing the square root covariance filter and square root information filter in dense or Hessenberg forms ACM Trans. Math. Software 15 243–256
Verhaegen M H G and van Dooren P (1986) Numerical aspects of different Kalman filter implementations IEEE Trans. Auto. Contr. AC-31 907–917

5  Arguments

1:     nIntegerInput
On entry: the actual state dimension, n , i.e., the order of the matrices S i  and A i -1 .
Constraint: n1 .
2:     mIntegerInput
On entry: the actual input dimension, m , i.e., the order of the matrix Q i - 1 / 2 .
Constraint: m1 .
3:     pIntegerInput
On entry: the actual output dimension, p , i.e., the order of the matrix R i+1 - 1 / 2 .
Constraint: p1 .
4:     inp_abNag_ab_inputInput
On entry: indicates how the matrix B i  is to be passed to the function.
inp_ab=Nag_ab_prod
Array b must contain the product A i -1 B i .
inp_ab=Nag_ab_sep
Then array b must contain B i .
5:     t[n×tdt]doubleInput/Output
Note: the i,jth element of the matrix T is stored in t[i-1×tdt+j-1].
On entry: the leading n  by n  upper triangular part of this array must contain S i -1  the square root of the inverse of the state covariance matrix P ii .
On exit: the leading n  by n  upper triangular part of this array contains S i+1 -1 , the square root of the inverse of the of the state covariance matrix P i + 1i + 1 .
6:     tdtIntegerInput
On entry: the stride separating matrix column elements in the array t.
Constraint: tdtn .
7:     ainv[n×tda]const doubleInput
Note: the i,jth element of the matrix is stored in ainv[i-1×tda+j-1].
On entry: the leading n  by n  part of this array must contain A i -1  the inverse of the state transition matrix.
8:     tdaIntegerInput
On entry: the stride separating matrix column elements in the array ainv.
Constraint: tdan .
9:     b[n×tdb]const doubleInput
Note: the i,jth element of the matrix B is stored in b[i-1×tdb+j-1].
On entry: the leading n  by m  part of this array must contain B i  (if inp_ab=Nag_ab_sep) or its product with A i -1  (if inp_ab=Nag_ab_prod).
10:   tdbIntegerInput
On entry: the stride separating matrix column elements in the array b.
Constraint: tdbm .
11:   rinv[p×tdr]const doubleInput
Note: the i,jth element of the matrix is stored in rinv[i-1×tdr+j-1].
On entry: if the measurement noise covariance matrix is to be supplied separately from the output weight matrix, then the leading p  by p  upper triangular part of this array must contain R i+1 - 1 / 2 , the right Cholesky factor of the inverse of the measurement noise covariance matrix. If this information is not to be input separately from the output weight matrix (see below) then the array rinv must be set to NULL.
12:   tdrIntegerInput
On entry: the stride separating matrix column elements in the array rinv.
Constraint: tdrp  if rinv is defined.
13:   c[p×tdc]const doubleInput
Note: the i,jth element of the matrix C is stored in c[i-1×tdc+j-1].
On entry: if the array rinv has been set to NULL then the leading p  by n  part of this array must contain C i+1 , the output weight matrix (or its product with R i+1 - 1 / 2 ) of the discrete system at instant i+1 .
14:   tdcIntegerInput
On entry: the stride separating matrix column elements in the array c.
Constraint: tdcn .
15:   qinv[m×tdq]const doubleInput
Note: the i,jth element of the matrix is stored in qinv[i-1×tdq+j-1].
On entry: the leading m  by m  upper triangular part of this array must contain Q i - 1 / 2  the right Cholesky factor of the inverse of the process noise covariance matrix.
16:   tdqIntegerInput
On entry: the stride separating matrix column elements in the array qinv.
Constraint: tdqm .
17:   x[n]doubleInput/Output
On entry: this array must contain the estimated state X ^ ii
On exit: the estimated state X ^ i + 1i + 1 .
18:   rinvy[p]const doubleInput
On entry: this array must contain R i+1 - 1 / 2 Y i+1 , the product of the upper triangular matrix R i+1 - 1 / 2  and the measured output Y i+1 .
19:   z[m]const doubleInput
On entry: this array must contain w - i , the mean value of the state process noise.
20:   toldoubleInput
On entry: tol is used to test for near singularity of the matrix S i+1 -1 . If you set tol to be less than n 2 × ε  then the tolerance is taken as n 2 × ε , where ε  is the machine precision.
21:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_2_INT_ARG_LT
On entry, tda=value  while n=value . These arguments must satisfy tdan .
On entry, tdb=value  while m=value . These arguments must satisfy tdbm .
On entry, tdc=value  while n=value . These arguments must satisfy tdcn .
On entry, tdq=value  while m=value . These arguments must satisfy tdqm .
On entry, tdr=value  while p=value . These arguments must satisfy tdrp .
On entry, tdt=value  while n=value . These arguments must satisfy tdtn .
NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_BAD_PARAM
On entry, argument inp_ab had an illegal value.
NE_INT_ARG_LT
On entry, m=value.
Constraint: m1.
On entry, n=value.
Constraint: n1.
On entry, p=value.
Constraint: p1.
NE_MAT_SINGULAR
The matrix inverse(S) is singular.

7  Accuracy

The use of the square root algorithm improves the stability of the computations.

8  Parallelism and Performance

Not applicable.

9  Further Comments

The algorithm requires approximately 7 6 n 3 + n 2 7 2 m + p + n 1 2 p 2 + m 2  operations and is backward stable (see Verhaegen and van Dooren (1986)).

10  Example

To apply three iterations of the Kalman filter (in square root information form) to the system A i -1 , A i -1 B i , C i+1 . The same data is used for all three iterative steps.

10.1  Program Text

Program Text (g13ecce.c)

10.2  Program Data

Program Data (g13ecce.d)

10.3  Program Results

Program Results (g13ecce.r)


nag_kalman_sqrt_filt_info_var (g13ecc) (PDF version)
g13 Chapter Contents
g13 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2014