-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathkalman-folding-03-008-derivations.tex
1855 lines (1660 loc) · 52.7 KB
/
kalman-folding-03-008-derivations.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% Created 2016-09-09 Fri 21:03
\documentclass[10pt,oneside,x11names]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{palatino}
\usepackage{siunitx}
\usepackage{esdiff}
\usepackage{xfrac}
\usepackage{nicefrac}
\usepackage{faktor}
\usepackage[euler-digits,euler-hat-accent]{eulervm}
\author{Brian Beckman}
\date{\textit{<2016-05-03 Tue>}}
\title{Kalman Folding 3: Derivations (Review Draft)\\\medskip
\large Extracting Models from Data, One Observation at a Time}
\hypersetup{
pdfauthor={Brian Beckman},
pdftitle={Kalman Folding 3: Derivations (Review Draft)},
pdfkeywords={},
pdfsubject={},
pdfcreator={Emacs 24.5.1 (Org mode 8.3.4)},
pdflang={English}}
\begin{document}
\maketitle
\setcounter{tocdepth}{3}
\tableofcontents
\section{Abstract}
\label{sec:orgheadline1}
In \emph{Kalman Folding, Part 1},\footnote{B. Beckman, \emph{Kalman Folding, Part 1}, \url{http://vixra.org/abs/1606.0328}.} we present basic, static Kalman filtering
as a functional fold, highlighting the unique advantages of this form for
deploying test-hardened code verbatim in harsh, mission-critical environments.
The examples in that paper are all static, meaning that the states of the model
do not depend on the independent variable, often physical time.
Here, we present mathematical derivations of the basic, static filter. These are
semi-formal sketches that leave many details to the reader, but highlight all
important points that must be rigorously proved. These derivations have several
novel arguments and we strive for much higher clarity and simplicity than is
found in most treatments of the topic.
\section{Kalman Folding}
\label{sec:orgheadline2}
In \emph{Kalman Folding, Part 1},\footnotemark[1]{} we found the following small formulation for the
accumulator function of a fold that implements the static Kalman filter:
\begin{equation}
\label{eqn:kalman-cume-definition}
\text{kalmanStatic}
\left(
\mathbold{Z}
\right)
\left(
\left\{
\mathbold{x},
\mathbold{P}
\right\},
\left\{
\mathbold{A},
\mathbold{z}
\right\}
\right) =
\left\{
\mathbold{x}+
\mathbold{K}\,
\left(
\mathbold{z}-
\mathbold{A}\,
\mathbold{x}
\right),
\mathbold{P}-
\mathbold{K}\,
\mathbold{D}\,
\mathbold{K}^\intercal
\right\}
\end{equation}
\noindent where
\begin{align}
\label{eqn:kalman-gain-definition}
\mathbold{K}
&=
\mathbold{P}\,
\mathbold{A}^\intercal\,
\mathbold{D}^{-1} \\
\label{eqn:kalman-denominator-definition}
\mathbold{D}
&= \mathbold{Z} +
\mathbold{A}\,
\mathbold{P}\,
\mathbold{A}^\intercal
\end{align}
\noindent and all quantities are matrices:
\begin{itemize}
\item \(\mathbold{z}\) is a \({b}\times{1}\) column vector containing one multidimensional observation
\item \(\mathbold{x}\) is an \({n}\times{1}\) column vector of \emph{model states}
\item \(\mathbold{Z}\) is a \({b}\times{b}\) matrix, the covariance of
observation noise
\item \(\mathbold{P}\) is an \({n}\times{n}\) matrix, the theoretical
covariance of \(\mathbold{x}\)
\item \(\mathbold{A}\) is a \({b}\times{n}\) matrix, the \emph{observation partials}
\item \(\mathbold{D}\) is a \({b}\times{b}\) matrix, the Kalman denominator
\item \(\mathbold{K}\) is an \({n}\times{b}\) matrix, the Kalman gain
\end{itemize}
In physical or engineering applications, these quantities carry physical
dimensions of units of measure in addition to their matrix dimensions as numbers
of rows and columns.
If the physical and matrix dimensions of
\(\mathbold{x}\)
are
\(\left[\left[\mathbold{x}\right]\right]
\stackrel{\text{\tiny def}}{=}
(\mathcal{X}, n\times{1})\)
and of
\(\mathbold{z}\)
are
\(\left[\left[\mathbold{z}\right]\right]
\stackrel{\text{\tiny def}}{=}
(\mathcal{Z}, b\times{1})\), then
\begin{equation}
\label{eqn:dimensional-breakdown}
\begin{array}{lccccr}
\left[\left[\mathbold{Z}\right]\right] &=& (&\mathcal{Z}^2 & b\times{b}&) \\
\left[\left[\mathbold{A}\right]\right] &=& (&\mathcal{Z}/\mathcal{X} & b\times{n}&) \\
\left[\left[\mathbold{P}\right]\right] &=& (&\mathcal{X}^2 & n\times{n}&) \\
\left[\left[\mathbold{A}\,\mathbold{P}\,\mathbold{A}^\intercal\right]\right] &=& (&\mathcal{Z}^2 & b\times{b}&) \\
\left[\left[\mathbold{D}\right]\right] &=& (&\mathcal{Z}^2 & b\times{b}&) \\
\left[\left[\mathbold{P}\,\mathbold{A}^\intercal\right]\right] &=& (&\mathcal{X}\,\mathcal{Z} & n\times{b}&) \\
\left[\left[\mathbold{K}\right]\right] &=& (&\mathcal{X}/\mathcal{Z} & n\times{b}&)
\end{array}
\end{equation}
Dimensional arguments, regarding both matrix dimensions and physical dimensions,
are invaluable for checking the derivations that follow.
\section{Derivations}
\label{sec:orgheadline17}
Below, we derive equations \ref{eqn:kalman-cume-definition},
\ref{eqn:kalman-gain-definition} and \ref{eqn:kalman-denominator-definition}.
Again, these derivations are just sketches designed for clarity as opposed to
rigorous proofs.
These derivations only cover the
static Kalman filter, where \(\mathbold{x}\) are
fixed, constant, static states of the model. See Bar-Shalom\footnote{Bar-Shalom, Yaakov, \emph{et al}. Estimation with applications to tracking and navigation. New York: Wiley, 2001.} for
derivations of the Kalman filter with time-dependent states and part 2 of this series\footnote{B. Beckman, \emph{Kalman Folding 2: Tracking and System Dynamics}, \url{http://vixra.org/abs/1606.0348}.} for
an example.
The plan is first to develop expressions for the prior estimate
\(\tilde{\mathbold{x}}\) and prior covariance \(\tilde{\mathbold{P}}\), and then expressions
for the posterior versions \(\hat{\mathbold{x}}\) and \(\hat{\mathbold{P}}\),
defining the Kalman gain \(\mathbold{K}\) matrix and the denominator matrix
\(\mathbold{D}\) along the way. Finally, we derive the particular, convenient expressions for \(\mathbold{K}\)
and \(\mathbold{D}\) that appear in equations \ref{eqn:kalman-cume-definition},
\ref{eqn:kalman-gain-definition}, and \ref{eqn:kalman-denominator-definition}.
Bierman laid out this strategy for the derivation in his classic book
\emph{Factorization Methods for Discrete Sequential Estimation}.\footnote{\url{http://tinyurl.com/h3jh4kt}} We follow
his plan, unpacking many of his elided steps for greater clarity.
\subsection{Notation}
\label{sec:orgheadline4}
The word \emph{vector} alone means \emph{column vector} by default. If a quantity is a row
vector, we explicitly say so. In general, lower-case boldface symbols like
\(\mathbold{x}\) denote column vectors. Row vectors include a superscript
\emph{transpose} symbol, as in \(\mathbold{a}^\intercal\). We write literal vectors in
square brackets, as in \(\left[a, b, \ldots\right]^\intercal\) for a column vector
or \(\left[a, b, \ldots\right]\) for a row vector or for cases where we don't care
whether it's a column or row.
Upper-case
boldface symbols like \(\mathbold{M}\) denote matrices. Our matrices are not
always square. Because vectors are
special cases of matrices, some matrices are also vectors. We may use an
upper-case symbol to denote a vector, but we do not use a lower-case symbol to
denote a non-vector matrix.
Juxtaposition, as in
\(\mathbold{A}\,\mathbold{x}\) or \(\mathbold{A}\,\mathbold{B}\), means matrix
multiplication.
When we write a product like
\(\mathbold{A}\,\mathbold{B}\), we assume that the number of columns of
\(\mathbold{A}\) matches the number of rows of \(\mathbold{B}\).
Matrix multiplication is non-commutative, meaning that
\(\mathbold{A}\,\mathbold{B}\) does not, in general, equal
\(\mathbold{B}\,\mathbold{A}\). However, if a matrix \(\mathbold{D}\) is square and
diagonal,
meaning that it has non-zero entries only along its main diagonal from upper
left to lower right, then \(\mathbold{A}\,\mathbold{D}\) does always equal
\(\mathbold{D}\,\mathbold{A}\). We may freely use this fact without mentioning it
explicitly.
Symmetric matrices do not always
commute, even with other symmetric matrices. In particular, the product of two
symmetric matrices is not always symmetric, as witnessed by the following
counterexample:
\begin{equation*}
\left(
\begin{array}{cc}
1 & 2 \\
2 & 3 \\
\end{array}
\right)\cdot\left(
\begin{array}{cc}
4 & 5 \\
5 & 6 \\
\end{array}
\right)
=
\left(
\begin{array}{cc}
14 & 17 \\
23 & 28 \\
\end{array}
\right)
\end{equation*}
Matrix multiplication is associative, meaning that the order in which pairwise
multiplications is carried out does not matter. Thus
\[(\mathbold{A}\,\mathbold{B})\,\mathbold{C}=\mathbold{A}\,(\mathbold{B}\,\mathbold{C})=\mathbold{A}\,\mathbold{B}\,\mathbold{C}\]
\noindent and we don't need to write parentheses. That means
some expressions of long products can be hard to read. We occasionally use
a center dot or \(\times\) symbol to make multiplication easier to read, as in
\(\mathbold{A}\cdot\mathbold{x}\) or \(\mathbold{A}\times\mathbold{x}\). We also use
the \(\times\) symbol when discussing the numbers of rows and columns of a matrix,
as in ``\(\mathbold{A}\) is an \(m\times n\) matrix,'' meaning that \(\mathbold{A}\)
has \(m\) rows and \(n\) columns.
We may freely exploit the following facts without mentioning them explicitly:
\begin{itemize}
\item For any matrix \(\mathbold{M}\), \(\left(\mathbold{M}^\intercal\right)^\intercal = \mathbold{M}\)
\item For any invertible matrix \(\mathbold{M}\), \(\left(\mathbold{M}^{-1}\right)^{-1} = \mathbold{M}\)
\item For any two matrices \(\mathbold{A}\) and
\(\mathbold{B}\),
\(\left(\mathbold{A}\,\mathbold{B}\right)^\intercal=\mathbold{B}^\intercal\mathbold{A}^\intercal\)
\item \(\left(\mathbold{A}\,\mathbold{B}\right)^{-1}=\mathbold{B}^{-1}\mathbold{A}^{-1}\)
when the matrices are invertible
\item \(\mathbold{P}^\intercal\) = \(\mathbold{P}\) if and only if \(\mathbold{P}\) is
symmetric
\end{itemize}
For any matrix \(\mathbold{M}\), \(\mathbold{M}^2\) means
\(\mathbold{M}^\intercal\mathbold{M}\), the transpose of the matrix times the
matrix. Such squared matrices are always square and symmetric.
This notation pertains to vectors, as well, because they are just
special cases of matrices. Thus,
\(\mathbold{x}^2=\mathbold{x}^\intercal\mathbold{x}\), the square of the Euclidean
\(\mbox{2-\textrm{norm}}\) of \(\mathbold{x}\), a scalar; and
\((\mathbold{x}^\intercal)^2 =
(\mathbold{x}^\intercal)^\intercal\cdot
\mathbold{x}^\intercal=
\mathbold{x}\,\mathbold{x}^\intercal\)
is the outer product of \(\mathbold{x}\) with itself; that outer product is an
\(n\times{n}\) square, symmetric matrix, where \(n\) is the dimensionality of \(\mathbold{x}\).
When \(\mathbold{M}^2\) is invertible, \(\mathbold{M}^{-2}\)
means the inverse of \(\mathbold{M}^2\), namely
\(\left(\mathbold{M}^\intercal\mathbold{M}\right)^{-1}\).
We use the term \emph{tall} to mean a matrix with more rows than columns, that is, an
\(m\times{n}\)
matrix when
\(m>n\). When discussing
\(m\times{n}\)
matrices, we usually assume that
\(m>n\).
We use the term \emph{wide} to mean a matrix with
more columns than rows, as in an \(n\times{m}\) matrix. We use the term \emph{small} to
mean \(n\times{n}\), and \emph{large} to mean \(m\times{m}\).
\subsubsection{Probability and Statistics}
\label{sec:orgheadline3}
We use the terms \emph{distribution} and \emph{expectation value} without definition in
this paper. If \(\mathbold{x}\) is a random variable, then we denote the
expectation value of some function \(f\) of \(\mathbold{x}\) as \(E[f(\mathbold{x})]\).
\subsection{Definitions}
\label{sec:orgheadline5}
\begin{description}
\item[{\(t\)}] is the independent variable. In many applications, \(t\) represents physical
time, or an integer index mapped to physical time. It is known and
non-random. We treat it as a scalar, here, though it is possible to extend
the theory to a vector \(t\).
\item[{\(\mathbold{x}\)}] is the (column) vector of \(n\) unknown, constant \emph{states}
of the model. It's a random variable, and we compute estimates and
covariances \emph{via} expectation values over its distribution. This symbol
also means an algebraic variable standing for some particular estimate of
the states.
\item[{\(\mathbold{A}\,\mathbold{x}\)}] is the \emph{model}; it predicts an observation at
time \(t\) given an estimate of the states \(\mathbold{x}\) and a current
partials matrix \(\mathbold{A}\) that may depend on \(t\). The model is a
column vector of dimensionality \(b\times{1}\), the same as the dimensionality of an
observation \(\mathbold{z}\).
\item[{\(\mathbold{A}\)}] is the \emph{current partials matrix}, the partial derivative of
the model with respect to the unknown states \(\mathbold{x}\), evaluated
at the current value of the independent variable \(t\). We could write
\(\mathbold{A}\) as \(\mathbold{A}(t)\); it's an
aesthetic judgment to omit explicit \(t\) dependence because it
would make the derivations longer and harder to read. Because the
model is \emph{linear}, the partials do not depend on \(\mathbold{x}\).
\(\mathbold{A}\) is known, non-random, and may depend on \(t\). Generally,
its dimensionality
is \(b\times{n}\), where \(b\) is the dimensionality of an
observation \(\mathbold{z}\).
\item[{\(\tilde{\mathbold{A}}\)}] is the \emph{prior partials matrix}, a matrix that stacks
all the prior rows of \(\mathbold{A}\) that precede the current row. It is
known, non-random, and \(m b\times{n}\), where \(m\) is the number of prior
observations, \(b\) is the dimensionality of a single
observation \(\mathbold{z}\), and \(n\) is the dimensionality of the states
\(\mathbold{x}\). Thus
\(\tilde{\mathbold{A}}\) is tall in the typical \emph{overdetermined} case where
\(m>n\), more observations than states. We do not actually
realize \(\tilde{\mathbold{A}}\) in computer memory because Kalman keeps
\emph{all information} in the running covariance matrix. \(\tilde{\mathbold{A}}\)
is just a
useful abstraction for the derivations below.
\item[{\(\mathbold{z}\)}] is the \emph{current observation}. It is known and non-random.
Its dimensionality is \(b\times{1}\).
\item[{\(\tilde{\mathbold{z}}\)}] is a stack of all prior observations. It
is known, non-random, \(m b\times{1}\). It's a useful abstraction in the
derivations below. It's not necessary to actually realize it in computer
memory because we use all its information incrementally by folding.
\item[{\({\tilde{\mathbold{x}}}\)}] the \emph{prior estimate}, the estimate of
\(\mathbold{x}\) given all information we have prior to the current
observation. It is known, non-random, \(n\times{1}\).
\item[{\({\hat{\mathbold{x}}}\)}] the \emph{posterior estimate}, the estimate of
\(\mathbold{x}\) given (1) the prior estimate \({\tilde{\mathbold{x}}}\), (2)
the current partials \(\mathbold{A}\), and (3) the current observation
\(\mathbold{z}\). It is known, non-random, \(n\times{1}\). It satisfies
\emph{the Kalman update equation}:
\end{description}
\begin{equation}
\label{eqn:kalman-update-equation}
{\hat{\mathbold{x}}} =
{\tilde{\mathbold{x}}} +
\mathbold{K}
\left(
\mathbold{z}-
\mathbold{A}\,
{\tilde{\mathbold{x}}}
\right)
\end{equation}
\noindent which is equivalent to the recurrence
\(\mathbold{x}\leftarrow\mathbold{x}+\mathbold{K}\,(z-\mathbold{A}\,\mathbold{x})\)
used in part 1 of this series.
\begin{description}
\item[{\({\tilde{\mathbold{P}}}\)}] \emph{covariance of the priors}, equals
\({\tilde{\mathbold{A}}}^{-2}\)
(de-dimensionalized; proof sketch
below). This is called just \(\mathbold{P}\) in part one of this series.
It is known, non-random, \(n\times{n}\).
\item[{\({\hat{\mathbold{P}}}\)}] \emph{posterior covariance}, satisfies
\({\hat{\mathbold{P}}}\,
{\mathbold{A}}^\intercal=
\mathbold{K}=
{\tilde{\mathbold{P}}}\,\mathbold{A}^\intercal\,\mathbold{D}^{-1}\)
(de-dimensionalized; proof sketch below). We calculate it from the prior covariance
\(\tilde{\mathbold{P}}\) and the new
partials matrix \(\mathbold{A}\).
It is known, non-random, \(n\times{n}\).
\item[{\(\mathbold{A}\,{\tilde{\mathbold{x}}}\)}] the \emph{predicted observation} given
the prior estimate \({\tilde{\mathbold{x}}}\) and the current partials matrix
\(\mathbold{A}\). It is a particular evaluation of the model. It is known,
non-random, \(b\times{1}\).
\item[{\(\mathbold{z}-\mathbold{A}\,{\tilde{\mathbold{x}}}\)}] the measurement
\emph{residual}, the difference between the current observation \(\mathbold{z}\) and the
predicted observation \(\mathbold{A}\,{\tilde{\mathbold{x}}}\).
\item[{\(\mathbold{\zeta}\)}] \emph{observation noise}: random column-vector with
zero mean and covariance \(\mathbold{Z}\) (unity, \(\mathbold{1}\), after
de-dimensionalization).
It has \(b\) rows and \(1\) column, like \(\mathbold{z}\).
\item[{\(\mathbold{Z}\)}] covariance of the observation noise, \(E
\left[
\mathbold{\zeta}\,
\mathbold{\zeta}^\intercal
\right]\): known, non-random \(b\times{b}\).
\item[{\(\tilde{\mathbold{z}} = \tilde{\mathbold{A}}\,{\mathbold{x}} + \mathbold{\zeta}\)}] the
\emph{observation equation}, which equates \(\tilde{\mathbold{z}}\), the stack of
all prior observations, to the product of \(\tilde{\mathbold{A}}\), the stack
of all prior partials matrices, and an unknown random vector of states,
\(\mathbold{x}\), plus some unknown random observation noise
\(\mathbold{\zeta}\). The stack of prior observations
\(\tilde{\mathbold{z}}\) is known, non-random, \(m b\times{1}\); the stack of prior
partials matrices
\(\tilde{\mathbold{A}}\) is known, non-random, \(m b\times{n}\); the state vector \({\mathbold{x}}\)
is unknown, random, \(n\times{1}\); The noise vector \(\mathbold{\zeta}\) is unknown, random,
\(m b\times{1}\). The observation equation looks similar to the expression for the residual
above. It's worthwhile to take a little time to examine the notations carefully and make sure
that you have a good mental picture of the meanings of these notations. The
observation equation looks tall in the typical, overdetermined case, where
as the residual is usually equivalent to a scalar expression.
\item[{\(\mathbold{K}\)}] \emph{Kalman gain}
\(=
{\tilde{\mathbold{P}}}\,
\mathbold{A}^\intercal\,
{\mathbold{D}}^{-1}\) (proof
sketch below).
Non-random, \(n\times{b}\).
\item[{\(\mathbold{D}\)}] \emph{Kalman denominator}
\(=
\mathbold{Z}+
\mathbold{A}\,
{\tilde{\mathbold{P}}}\,
\mathbold{A}^\intercal\),
or
\(\mathbold{1}+
\mathbold{A}\,
{\tilde{\mathbold{P}}}\,
\mathbold{A}^\intercal\)
de-dimensionalized.
(proof sketch below). Non-random, \(b\times{b}\).
\end{description}
\subsection{Demonstration that Prior Covariance \({\tilde{\mathbold{P}}} = \tilde{\mathbold{A}}^{-2}\)}
\label{sec:orgheadline11}
The fact that the prior covariance, \(\tilde{\mathbold{P}}\), equals the
the inverse square of
the stack of prior partials matrices (de-dimensionalized), \(\tilde{\mathbold{A}}^{-2}\), is the secret
to Kalman's efficient, in fact constant, use of computer memory. The stack of
prior partials matrices \(\tilde{\mathbold{A}}\) can be very tall and impractical
to store. But its square, \(\tilde{\mathbold{A}}^{2}\) is only \(n\times{n}\), and
its inverse square is also just \(n\times{n}\). Kalman packs all statistical
information about the model into this small matrix of constant size, and
incrementally improves the statistics as observations accumulate, without
increasing the size of the matrix, and thus without increasing the amount of
computer memory needed to keep all important information. The Kalman filter is
\emph{optimal}, meaning that the small covariance matrices keep all available
information. No other method would be able to squeeze more information out of
the observations and the model --- at least when the noise is Gaussian. A
rigorous optimality proof is out of scope for this paper, but the least-squares
derivation below contains the central idea: Kalman tracks the estimate and
covariance that minimize the sum of squared residuals. Kalman is optimal in the
sense that no other method would find a smaller sum of squared residuals.
\subsubsection{Covariance of Any Random Vector Variable}
\label{sec:orgheadline6}
The covariance of any random column vector \(\mathbold{y}\) is defined as the
expectation value
\(E
\left[
\mathbold{y}\,
\mathbold{y}^\intercal
\right]
=
E
\left[
({\mathbold{y}^\intercal})^2
\right]\)
\noindent This is the expectation value of an outer product of a column vector
\(\mathbold{y}\) and its transpose, \(\mathbold{y}^\intercal\). Therefore, it is a
\(q\times{q}\) matrix, where \(q\times{1}\) is the dimensionality of \(\mathbold{y}\).
\subsubsection{Prior Estimate \({\tilde{\mathbold{x}}}\)}
\label{sec:orgheadline7}
One of our random variables is \(\mathbold{x}\), the column \mbox{$n$-vector} of unknown
states. To calculate its estimate, assume we know the values of all \(m\) past
partials \({\tilde{\mathbold{A}}}\) (tall, \(m b\times{n}\)) and observations
\(\tilde{\mathbold{z}}\) (tall, \(m b\times{1}\)).
Relate \(\mathbold{x}\) to the known observations \({\tilde{\mathbold{z}}}\) and the known
partials \({\tilde{\mathbold{A}}}\) through the normally distributed random noise column
vector \(\mathbold{\zeta}\) and the \emph{observation equation}:
\begin{equation}
\label{eqn:observation-equation}
{\tilde{\mathbold{z}}}={\tilde{\mathbold{A}}}\,\mathbold{x}+\mathbold{\zeta}
\end{equation}
\subsubsection{Sum of Squared Residuals}
\label{sec:orgheadline8}
Consider the
following \emph{performance functional}, computed over the population of
\(\mathbold{x}\).
\begin{equation*}
J(\mathbold{x})
\stackrel{\text{\tiny def}}{=}
\zeta^2=
\left(
{\tilde{\mathbold{z}}}-
{\tilde{\mathbold{A}}}\,
\mathbold{x}
\right)^2=
\left(
{\tilde{\mathbold{z}}}-
{\tilde{\mathbold{A}}}\,
\mathbold{x}
\right)^\intercal
\cdot
\left(
{\tilde{\mathbold{z}}}-
{\tilde{\mathbold{A}}}\,
\mathbold{x}
\right)
\end{equation*}
\noindent \(J(\mathbold{x})\) is a scalar: the sum of squared residuals. A
\emph{residual} is a difference between an actual observation \(\mathbold{z}\) and a
predicted observation \(\mathbold{A}\,\mathbold{x}\). An \emph{actual observation}
\(\mathbold{z}\) is a known,
concrete \mbox{$b$-vector} of numbers, and the partials matrix \(\mathbold{A}\)
is a known, concrete \mbox{$(b\times n)$-matrix} of numbers
corresponding to that observation. The observation equation
\begin{itemize}
\item stacks all prior observations (known, concrete numbers) into
\(\tilde{\mathbold{z}}\)
\item stacks all prior
values of the partials matrix \(\mathbold{A}\) into \(\tilde{\mathbold{A}}\) (known,
concrete numbers)
\item multiplies by the unknown random state estimate
\(\mathbold{x}\) to get the (unknown, random)
predicted observations \({\tilde{\mathbold{A}}}\,\mathbold{x}\)
\item finally adds some
unknown random noise \(\mathbold{\zeta}\) (column vector of height \(m b\))
\end{itemize}
The performance functional collapses all that
information into a scalar random variable \(J(\mathbold{x})\) with the same (Gaussian) distribution
as the noise \(\mathbold{\zeta}\). Recall that any \emph{random variable} is, in fact,
always a
function, even if only the identity function, as when we say that \(\mathbold{x}\)
is a random variable. This is the standard nomenclature of probability and
statistics established by Kolmogorov, and it admittedly can be confusing.
The job of finding the optimal estimate of the state vector \(\mathbold{x}\) is
the job of finding the concrete, numerical value of \(\mathbold{x}\) that minimizes the
performance functional \(J(\mathbold{x})\), which depends on all the known,
non-random, concrete numbers in \(\tilde{\mathbold{z}}\) and \(\tilde{\mathbold{A}}\).
To
find the \(\mathbold{x}\) that minimizes \(J(\mathbold{x})\), we could take the
classic, school approach of setting to zero the partial derivatives of
\(J(\mathbold{x})\) with respect to \(\mathbold{x}\) and solving the resulting
equations for \(\mathbold{x}\). The following is an easier way. Multiply the
residuals across by the wide matrix \({\tilde{\mathbold{A}}}^\intercal\):
\begin{equation*}
{\tilde{\mathbold{A}}}^\intercal\,
{\tilde{\mathbold{z}}} -
{\tilde{\mathbold{A}}}^2\,
\mathbold{x}
\end{equation*}
\noindent producing an \mbox{$n$-vector}, and then construct a
modified performance functional:
\begin{equation*}
J'(\mathbold{x})
\stackrel{\text{\tiny def}}{=}
\left(
{\tilde{\mathbold{A}}}^\intercal\,
{\tilde{\mathbold{z}}} -
{\tilde{\mathbold{A}}}^2\,
\mathbold{x}
\right)^2
=
\left(
{\tilde{\mathbold{A}}}^\intercal\,
{\tilde{\mathbold{z}}} -
{\tilde{\mathbold{A}}}^2\,
\mathbold{x}
\right)^\intercal
\cdot
\left(
{\tilde{\mathbold{A}}}^\intercal\,
{\tilde{\mathbold{z}}} -
{\tilde{\mathbold{A}}}^2\,
\mathbold{x}\right)
\end{equation*}
\noindent \(J(\mathbold{x})\) is minimum with respect to \(\mathbold{x}\) if and
only if (iff) \(J'(\mathbold{x})\) is minimum (this assertion needs a rigorous
proof; as warned, we present only sketches in this paper). Because
\(J'(\mathbold{x})\) is non-negative, when \(J'(\mathbold{x})\) \emph{can} be zero, its
minimum \emph{must} be zero. \(J'(\mathbold{x})\) is zero iff
\({\tilde{\mathbold{A}}}^2\), an \(n\times{n}\) square matrix, is invertible
(non-singular), in which case
\begin{equation*}
\mathbold{x}=
{\tilde{\mathbold{A}}}^{-2}\,
{\tilde{\mathbold{A}}}^\intercal\,
{\tilde{\mathbold{z}}}
\end{equation*}
\noindent produces that minimum value of \(J'(\mathbold{x})\), because then
\begin{equation*}
{\tilde{\mathbold{A}}}^\intercal\,
{\tilde{\mathbold{z}}}=
{\tilde{\mathbold{A}}}^2\,
\mathbold{x}
\end{equation*}
We call such a solution for \(\mathbold{x}\) the \emph{least-squares estimate} of
\(\mathbold{x}\): the estimate of
\(\mathbold{x}\) based on all prior observations.
From now on, we write it as \({\tilde{\mathbold{x}}}\)
\begin{equation}
\label{eqn:least-squares-estimate}
\tilde{\mathbold{x}}
\stackrel{\text{\tiny def}}{=}
{\tilde{\mathbold{A}}}^{-2}
{\tilde{\mathbold{A}}}^\intercal
{\tilde{\mathbold{z}}}
\end{equation}
With this solution, we get a new expression for the performance functional
\(J(\mathbold{x})\) that is useful below. First note that
\begin{alignat}{6}
\notag
{\tilde{\mathbold{A}}}^2\,
{\tilde{\mathbold{A}}}^{-2}
&=
\mathbold{1}
&& \text{}
\\
\notag
{\tilde{\mathbold{A}}}^2\,
{\tilde{\mathbold{A}}}^{-2}
{\tilde{\mathbold{A}}}^\intercal
&=
{\tilde{\mathbold{A}}}^\intercal
&&
\quad\text{Multiply on right by }\tilde{\mathbold{A}}^\intercal
\\
\notag
({\tilde{\mathbold{A}}}^\intercal\,
{\tilde{\mathbold{A}}})\,
{\tilde{\mathbold{A}}}^{-2}
{\tilde{\mathbold{A}}}^\intercal
&=
{\tilde{\mathbold{A}}}^\intercal
&&
\quad\text{Expand definition of }{\tilde{\mathbold{A}}}^2
\\
\label{eqn:aa2at-is-one}
\mathrm{therefore}\quad
{\tilde{\mathbold{A}}}\,
{\tilde{\mathbold{A}}}^{-2}\,
{\tilde{\mathbold{A}}}^\intercal
&=
\mathbold{1}
&&
\quad\text{Arbitrariness of }\tilde{\mathbold{A}}^\intercal\text{on left}
\end{alignat}
\noindent Equation \ref{eqn:aa2at-is-one} is another assertion that requires a
rigorous proof, out of scope for this paper of sketches. But, assuming it is
true, we have
\begin{alignat}{6}
\notag
J(\mathbold{x})
&=
\left(
{\tilde{\mathbold{z}}}-
{\tilde{\mathbold{A}}}\,
\mathbold{x}
\right)^\intercal
\cdot
\left(
{\tilde{\mathbold{z}}}-
{\tilde{\mathbold{A}}}\,
\mathbold{x}
\right)
\\
\notag
&=
\left(
{\tilde{\mathbold{z}}}-
{\tilde{\mathbold{A}}}\,
\mathbold{x}
\right)^\intercal
{\tilde{\mathbold{A}}}\,
{\tilde{\mathbold{A}}}^{-2}\,
{\tilde{\mathbold{A}}}^\intercal
\left(
{\tilde{\mathbold{z}}}-
{\tilde{\mathbold{A}}}\,
\mathbold{x}
\right)
&&
\quad\text{insert }\mathbold{1}\text{ from equation \ref{eqn:aa2at-is-one}}
\\
\notag
&=
\left(
{\tilde{\mathbold{z}}}-
{\tilde{\mathbold{A}}}\,
\mathbold{x}
\right)^\intercal
{\tilde{\mathbold{A}}}\,
({\tilde{\mathbold{A}}}^{-2}\,
{\tilde{\mathbold{A}}}^2)\,
{\tilde{\mathbold{A}}}^{-2}\,
{\tilde{\mathbold{A}}}^\intercal
\left(
{\tilde{\mathbold{z}}}-
{\tilde{\mathbold{A}}}\,
\mathbold{x}
\right)
&&
\quad\text{insert }\mathbold{1} = {\tilde{\mathbold{A}}}^{-2}\,{\tilde{\mathbold{A}}}^{2}
\\
\notag
&=
\left[
\left(
{\tilde{\mathbold{z}}}-
{\tilde{\mathbold{A}}}\,
\mathbold{x}
\right)^\intercal
{\tilde{\mathbold{A}}}\,
{\tilde{\mathbold{A}}}^{-2}
\right]
{\tilde{\mathbold{A}}}^2
\left[
{\tilde{\mathbold{A}}}^{-2}\,
{\tilde{\mathbold{A}}}^\intercal
\left(
{\tilde{\mathbold{z}}}-
{\tilde{\mathbold{A}}}\,
\mathbold{x}
\right)
\right]
&&
\quad\text{Regroup}
\\
\notag
&=
\left[
{\tilde{\mathbold{A}}}^{-2}\,
{\tilde{\mathbold{A}}}^\intercal
\left(
{\tilde{\mathbold{z}}}-
{\tilde{\mathbold{A}}}\,
\mathbold{x}
\right)
\right]^\intercal
{\tilde{\mathbold{A}}}^2
\left[
{\tilde{\mathbold{A}}}^{-2}\,
{\tilde{\mathbold{A}}}^\intercal
\left(
{\tilde{\mathbold{z}}}-
{\tilde{\mathbold{A}}}\,
\mathbold{x}
\right)
\right]
&&
\quad\text{Symmetry of $\tilde{\mathbold{A}}$ and $\tilde{\mathbold{A}}^{-2}$}
\\
\label{eqn:performance-functional-reformed}
&=
(\tilde{\mathbold{x}}-\mathbold{x})^\intercal\,
{\tilde{\mathbold{A}}^2}\,
(\tilde{\mathbold{x}}-\mathbold{x})
&&
\quad\text{Definition of }{\tilde{\mathbold{x}}}\text{ from equation \ref{eqn:least-squares-estimate}}
\end{alignat}
\noindent
This has
physical dimensions \(\mathcal{Z}^2\) where \(\mathcal{Z}\) are the physical
dimensions of the observations \(\mathbold{z}\).
\subsubsection{Prior Covariance \(\tilde{\mathbold{P}}\)}
\label{sec:orgheadline9}
We now want the covariance of the residuals between
our least-squares estimate \(\tilde{\mathbold{x}}\) and the random vector
\(\mathbold{x}\):
\begin{align}
\label{eqn:covariance-of-x}
\tilde{\mathbold{P}}
\stackrel{\text{\tiny def}}{=}
E
\left[
(\tilde{\mathbold{x}}-\mathbold{x})
(\tilde{\mathbold{x}}-\mathbold{x})^\intercal
\right]
\end{align}
\noindent Get \(\tilde{\mathbold{x}}-\mathbold{x}\)
from the observations and partials at hand as follows:
\begin{alignat}{6}
\notag
{\tilde{\mathbold{z}}}
&=
{\tilde{\mathbold{A}}}\,
\mathbold{x} +
\mathbold{\zeta}
&&
\quad\text{the observation equation, Equation \ref{eqn:observation-equation}}
\\
\notag
{\tilde{\mathbold{A}}}^{-2}\,
{\tilde{\mathbold{A}}}^\intercal\,
{\tilde{\mathbold{z}}}
&=
\mathbold{x} +
{\tilde{\mathbold{A}}}^{-2}\,
{\tilde{\mathbold{A}}}^\intercal\,
\mathbold{\zeta}
&&
\quad\text{Multiply on left by }{\tilde{\mathbold{A}}}^{-2}\,\tilde{\mathbold{A}}^\intercal
\\
\notag
\tilde{\mathbold{x}}
&=
\mathbold{x} +
{\tilde{\mathbold{A}}}^{-2}\,
{\tilde{\mathbold{A}}}^\intercal\,
\mathbold{\zeta}
&&
\quad\text{Definition of }{\tilde{\mathbold{x}}}\text{ from equation \ref{eqn:least-squares-estimate}}
\\
\notag
\text{therefore}\quad
\tilde{\mathbold{x}} -
\mathbold{x} &=
{\tilde{\mathbold{A}}}^{-2}
{\tilde{\mathbold{A}}}^\intercal
\mathbold{\zeta}
\end{alignat}
\noindent
Now rewrite equation \ref{eqn:covariance-of-x}, the definition of the prior
covariance \(\tilde{\mathbold{P}}\):
\begin{align}
\notag
E
\left[
(\tilde{\mathbold{x}}-\mathbold{x})
(\tilde{\mathbold{x}}-\mathbold{x})^\intercal
\right] &=
E
\left[
{\tilde{\mathbold{A}}}^{-2}
{\tilde{\mathbold{A}}}^\intercal
\mathbold{\zeta}\,
\mathbold{\zeta}^\intercal
({\tilde{\mathbold{A}}}^{-2}
{\tilde{\mathbold{A}}}^\intercal
\mathbold{\zeta})^\intercal
\right] \\
\label{eqn:almost-final-covariance}
&=
{\tilde{\mathbold{A}}}^{-2}
{\tilde{\mathbold{A}}}^\intercal\,
E\left[
\mathbold{\zeta}\,
\mathbold{\zeta}^\intercal
\right]
({\tilde{\mathbold{A}}}^{-2}
{\tilde{\mathbold{A}}}^\intercal)^\intercal
\end{align}
\noindent We can collapse the expectation value inwards because the stack of
observation partials \(\tilde{\mathbold{A}}\) is a matrix of concrete, non-random
numbers.
Noise \(\mathbold{\zeta}\) is Gaussian, normal, with diagonal covariance
matrix \(\mathbold{Z}\), by hypothesis. Equation \ref{eqn:almost-final-covariance}
becomes
\begin{align}
\notag
\tilde{\mathbold{P}} =
{\tilde{\mathbold{A}}}^{-2}
{\tilde{\mathbold{A}}}^\intercal\,
E\left[
\mathbold{\zeta}\,\mathbold{\zeta}^\intercal
\right]
({\tilde{\mathbold{A}}}^{-2}
{\tilde{\mathbold{A}}}^\intercal)^\intercal
&=
\notag
{\tilde{\mathbold{A}}}^{-2}
{\tilde{\mathbold{A}}}^\intercal\,
\mathbold{Z}\,
({\tilde{\mathbold{A}}}^{-2}
{\tilde{\mathbold{A}}}^\intercal)^\intercal
\\
&=
\notag
{\tilde{\mathbold{A}}}^{-2}
{\tilde{\mathbold{A}}}^\intercal\,
\mathbold{Z}\,
{\tilde{\mathbold{A}}}
({\tilde{\mathbold{A}}}^{-2})^\intercal
\\
&=
\label{eqn:prior-covariance-convenient-form}
{\tilde{\mathbold{A}}}^{-2}
{\tilde{\mathbold{A}}}^\intercal\,
\mathbold{Z}\,
{\tilde{\mathbold{A}}}
({\tilde{\mathbold{A}}}^{-2})
\end{align}
\noindent because \(\tilde{\mathbold{A}}^{-2}\) is symmetric.
At this point, no further simplification is possible, in general, because
\(\mathbold{Z}\) is \(b\times b\) and can only be sandwiched between
\({\tilde{\mathbold{A}}}^\intercal\), \(n\times b\), and
\({\tilde{\mathbold{A}}}\), \(b\times n\). However, we can greatly simplify this and
all subsequent computations by de-dimensionalizing. There are numerical
benefits, as well, to be discussed in the next section.
\subsubsection{De-Dimensionalizing the Observation Equation}
\label{sec:orgheadline10}
Fully spelled out, and in the general case of \mbox{$b$-vector} observations
\(\mathbold{z}\), one block of height \(b\) of the observation equation is
\begin{equation*}
\left(
\begin{array}{c}
z_1 \\
z_2 \\
\vdots \\
z_b \\
\end{array}
\right)=\left(
\begin{array}{cccc}
A_{11} & A_{12} & \cdots & A_{1 n} \\
A_{21} & A_{22} & \cdots & A_{2 n} \\
\vdots & \vdots & \ddots & \vdots \\
A_{\text{b1}} & A_{\text{b2}} & \cdots & A_{b n} \\
\end{array}
\right) \left(