-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwriteup_regression.lyx
More file actions
1735 lines (1335 loc) · 34 KB
/
writeup_regression.lyx
File metadata and controls
1735 lines (1335 loc) · 34 KB
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
#LyX 2.3 created this file. For more info see http://www.lyx.org/
\lyxformat 544
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass article
\use_default_options true
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\use_microtype false
\use_dash_ligatures true
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\use_hyperref false
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 1
\use_minted 0
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\is_math_indent 0
\math_numbering_side default
\quotes_style english
\dynamic_quotes 0
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header
\begin_body
\begin_layout Standard
What you can read here can be found in books with more details.
The goal is to give an overview and a
\begin_inset Quotes eld
\end_inset
feeling
\begin_inset Quotes erd
\end_inset
for the topic, and to summarize thoughts that help to get the big picture
and relations between different approaches as well as pros and cons for
different applications.
\end_layout
\begin_layout Standard
Our mission is simple: we want to learn about an unknown function
\begin_inset Formula $f(\boldsymbol{x})$
\end_inset
depending on independent variables
\begin_inset Formula $\boldsymbol{x}=(x^{1},x^{2},\dots,x^{d})$
\end_inset
.
Here both,
\begin_inset Formula $\boldsymbol{x}$
\end_inset
and
\begin_inset Formula $f$
\end_inset
can be tuples, or vector-valued quantities in general, but mostly we treat
\begin_inset Formula $f$
\end_inset
as a scalar here for simplicity.
We are allowed to take samples of
\begin_inset Formula $f$
\end_inset
at a training points
\begin_inset Formula $X=(\boldsymbol{x}_{1},\boldsymbol{x}_{2},\dots,\boldsymbol{x}_{n})$
\end_inset
.
\end_layout
\begin_layout Section
Basics on bases
\end_layout
\begin_layout Standard
Let
\begin_inset Formula $\phi_{j}(\boldsymbol{x})$
\end_inset
be basis functions that approximate a function according to
\begin_inset Formula
\begin{equation}
f(\boldsymbol{x})\approx\sum_{j}f_{j}\phi_{j}(\boldsymbol{x}).\label{eq:fapprox}
\end{equation}
\end_inset
Inside the function space spanned by
\begin_inset Formula $\phi^{j}(\boldsymbol{x})$
\end_inset
this approximation becomes an identity.
E.g.
if we choose in 1D
\begin_inset Formula
\[
\phi_{0}(x)=1,\quad\phi_{1}(x)=x,\quad\phi_{2}(x)=x^{2},\dots\phi_{n}(x)=x^{n}
\]
\end_inset
to be powers of
\begin_inset Formula $x$
\end_inset
, we can exactly represent any polynomial up to degree
\begin_inset Formula $n$
\end_inset
.
We will see later that it's more convenient for fitting to use not just
monomials
\begin_inset Formula $x^{j}$
\end_inset
, but orthogonal polynomials (Legendre, Hermite, Laguerre, ...).
Apart from polynomials a typical example for such a global basis are sin/cos
functions, often written as complex exponentials
\begin_inset Formula
\[
\phi_{-2}(x)=e^{-2ix},\quad\phi_{-1}(x)=e^{-ix},\quad\phi_{0}(x)=1,\phi_{1}(x)=e^{ix},\dots
\]
\end_inset
where the index
\begin_inset Formula $j$
\end_inset
runs from
\begin_inset Formula $-(n-1)/2$
\end_inset
to
\begin_inset Formula $(n-1)/2$
\end_inset
for
\begin_inset Formula $n$
\end_inset
terms.
Such a Fourier series allows to represent any trigonometric function that
is periodic in the domain
\begin_inset Formula $(0,2\pi)$
\end_inset
up to a certain wavenumber, i.e.
\begin_inset Quotes eld
\end_inset
wigglyness
\begin_inset Quotes erd
\end_inset
.
\end_layout
\begin_layout Standard
For the case when we are outside the span (= linear hull) of
\begin_inset Formula $\{\phi_{j}\}$
\end_inset
we have to ask ourselves what we mean by a good approximation.
For this purpose we have to define what it means that two functions are
\begin_inset Quotes eld
\end_inset
close
\begin_inset Quotes erd
\end_inset
to each other.
\end_layout
\begin_layout Section
Collocation
\end_layout
\begin_layout Standard
We can pretend (
\begin_inset CommandInset ref
LatexCommand ref
reference "eq:fapprox"
\end_inset
) to be exact and solve, for a number of training points
\begin_inset Formula $\boldsymbol{x}_{i}$
\end_inset
the system
\begin_inset Formula
\begin{equation}
f(\boldsymbol{x}_{i})\approx\sum_{j}f_{j}\phi_{j}(\boldsymbol{x}_{i}).\label{eq:fapprox-2}
\end{equation}
\end_inset
Here we obtain a (usually non-symmetric or rectangular) collocation matrix
\begin_inset Formula
\begin{equation}
\Phi_{ij}=\phi_{j}(\boldsymbol{x}_{i})
\end{equation}
\end_inset
and a right-hand-side
\begin_inset Formula
\begin{equation}
y_{i}=f(\boldsymbol{x}_{i})
\end{equation}
\end_inset
to solve
\begin_inset Formula
\begin{equation}
\Phi\boldsymbol{f}=\boldsymbol{y}
\end{equation}
\end_inset
in a least-squares sense, i.e.
minimize
\begin_inset Formula
\begin{equation}
\frac{1}{2}\boldsymbol{f}^{T}\Phi\boldsymbol{f}-\boldsymbol{y}^{T}\boldsymbol{f}.
\end{equation}
\end_inset
This is a minimization in
\emph on
coefficient
\emph default
space, which is a somewhat strange space to optimize in.
\end_layout
\begin_layout Standard
In the special case of radial basis functions where
\begin_inset Formula
\begin{equation}
\phi_{j}(\boldsymbol{x})=k(\boldsymbol{x}-\boldsymbol{x}_{j})
\end{equation}
\end_inset
we obtain a symmetric matrix if we use as many training points as basis
functions.
\end_layout
\begin_layout Section
Projection
\end_layout
\begin_layout Standard
Projection yields the best approximation in the sense of the
\begin_inset Formula $L_{2}$
\end_inset
(or a similar) norm
\begin_inset Formula $||f-\tilde{f}||$
\end_inset
.
This is analogous to minimizing the length of the vector
\begin_inset Formula $f-\tilde{f}$
\end_inset
in an (
\begin_inset Formula $\infty$
\end_inset
-dimensional) vector space.
For this we introduce an inner product
\begin_inset Formula $\left\langle f,g\right\rangle $
\end_inset
that generalizes the scalar product
\begin_inset Formula $\boldsymbol{u}\cdot\boldsymbol{v}$
\end_inset
and boils down to integrals
\begin_inset Formula
\begin{equation}
\left\langle f,g\right\rangle =\int_{\Omega}w(\boldsymbol{x})f(\boldsymbol{x})g(\boldsymbol{x})d\boldsymbol{x}.
\end{equation}
\end_inset
Here we leave a free weight function
\begin_inset Formula $w(\boldsymbol{x})$
\end_inset
in addition to just the product of
\begin_inset Formula $f(\boldsymbol{x})$
\end_inset
and
\begin_inset Formula $g(\boldsymbol{x})$
\end_inset
to be more general, and define
\begin_inset Formula $||f||=\sqrt{\left\langle f,f\right\rangle }$
\end_inset
.
Taking an inner product of (
\begin_inset CommandInset ref
LatexCommand ref
reference "eq:fapprox"
\end_inset
) with a basis function
\begin_inset Formula $\phi_{i}$
\end_inset
yields
\begin_inset Formula
\begin{equation}
\left\langle \phi_{i},f\right\rangle \approx\sum_{j}\left\langle \phi_{i},\phi_{j}\right\rangle f_{j}.\label{eq:fapprox-1}
\end{equation}
\end_inset
Due to linearity we could just pull the inner product inside the sum on
the right-hand side.
Again we can find
\begin_inset Formula $f_{j}$
\end_inset
like in the regression case by solving a linear system
\begin_inset Formula
\begin{equation}
M\boldsymbol{f}=\boldsymbol{b}
\end{equation}
\end_inset
where
\begin_inset Formula
\begin{equation}
M_{ij}=\left\langle \phi_{i},\phi_{j}\right\rangle ,\qquad b_{i}=\left\langle \phi_{i},f\right\rangle .
\end{equation}
\end_inset
\end_layout
\begin_layout Standard
Usually
\begin_inset Formula $M$
\end_inset
is called the mass matrix here.
Most importantly, for cleverly chosen sets of basis functions with the
right function
\begin_inset Formula $w(\boldsymbol{x})$
\end_inset
we can compute
\begin_inset Formula $f_{j}$
\end_inset
directly by making
\begin_inset Formula $M$
\end_inset
diagonal.
In a trigonometric (Fourier) basis we know that
\begin_inset Formula
\begin{equation}
\frac{1}{2\pi}\int_{0}^{2\pi}\phi_{i}(x)\phi_{j}(x)dx=\delta_{ij}\equiv\begin{cases}
1 & i=j\\
0 & \mathrm{otherwise}
\end{cases}.
\end{equation}
\end_inset
This is why we will just use
\begin_inset Formula
\begin{equation}
\left\langle f,g\right\rangle _{\mathrm{trig}}=\frac{1}{2\pi}\int_{0}^{2\pi}f(x)g(x)dx.
\end{equation}
\end_inset
in that case.
We obtain a unity mass matrix with
\begin_inset Formula $M_{ij}=\delta_{ij}$
\end_inset
and thus
\begin_inset Formula
\begin{equation}
f_{i}=\frac{1}{2\pi}\int_{0}^{2\pi}\phi_{i}(x)f(x)dx.
\end{equation}
\end_inset
More generally, we will try to find
\begin_inset Formula $w(\boldsymbol{x})$
\end_inset
such that
\begin_inset Formula
\begin{equation}
\left\langle \phi_{i},\phi_{j}\right\rangle =\int_{\Omega}w(\boldsymbol{x})\phi_{i}(\boldsymbol{x})\phi_{j}(\boldsymbol{x})d\boldsymbol{x}=\delta_{ij}.
\end{equation}
\end_inset
This is called the orthogonality condition.
We already saw that for
\end_layout
\begin_layout Itemize
periodic functions in
\begin_inset Formula $\Omega=(0,2\pi)$
\end_inset
, use trigonometric basis with constant
\begin_inset Formula $w(x)=(2\pi)^{-1}$
\end_inset
.
\end_layout
\begin_layout Standard
Polynomial bases that support such an orthogonality condition are called
orthogonal polynomials.
Applications are for
\end_layout
\begin_layout Itemize
general functions in
\begin_inset Formula $\Omega=(-1,1)$
\end_inset
, use Legendre polynomials with constant
\begin_inset Formula $w(x)=1$
\end_inset
\end_layout
\begin_layout Itemize
decaying functions in
\begin_inset Formula $\Omega=(-\infty,\infty)$
\end_inset
, use Her
\family roman
\series medium
\shape up
\size normal
\emph off
\bar no
\strikeout off
\xout off
\uuline off
\uwave off
\noun off
\color none
\backslash
boldsymbol{y}
\backslash
mathcal{L}^{
\backslash
prime}
\family default
\series default
\shape default
\size default
\emph default
\bar default
\strikeout default
\xout default
\uuline default
\uwave default
\noun default
\color inherit
mite polynomials
\begin_inset Formula $H_{j}(x)$
\end_inset
with
\begin_inset Formula $w(x)=e^{-x^{2}}$
\end_inset
\end_layout
\begin_deeper
\begin_layout Itemize
more cleverly, use Hermite functions
\begin_inset Formula $h_{j}(x)=e^{-x^{2}/2}H_{j}(x)$
\end_inset
with
\begin_inset Formula $w(x)=1$
\end_inset
.
They don't explode.
\end_layout
\end_deeper
\begin_layout Standard
Even if we don't get an exact orthogonality condition, we can often get
very local coupling such that
\begin_inset Formula $M$
\end_inset
becomes a banded or sparse matrix with many zeros.
This is the case when using a local finite element or spline basis of low
order.
The higher the order, the more global the coupling becomes, and a orthogonal,
spectral basis may be a better choice.
\end_layout
\begin_layout Section
Least squares / Linear regression
\end_layout
\begin_layout Standard
We now want to minimize the squared distance to the training data.
Defining the design matrix
\begin_inset Formula $\Phi$
\end_inset
with
\begin_inset Formula $\Phi_{ij}=\phi_{j}(\boldsymbol{x}_{i})$
\end_inset
, we minimize
\end_layout
\begin_layout Standard
\begin_inset Formula
\begin{align}
\sum_{i}(\sum_{j}f_{j}\phi_{j}(\boldsymbol{x}_{i})-y_{i})^{2} & =(\Phi^{T}\boldsymbol{f}-\boldsymbol{y})^{T}(\Phi^{T}\boldsymbol{f}-\boldsymbol{y})\nonumber \\
& =\boldsymbol{f}^{T}\Phi\Phi^{T}\boldsymbol{f}-2\boldsymbol{y}^{T}\Phi^{T}\boldsymbol{f}+\boldsymbol{y}^{T}\boldsymbol{y}.
\end{align}
\end_inset
with respect to coefficients
\begin_inset Formula $\boldsymbol{f}$
\end_inset
at given data
\begin_inset Formula $\boldsymbol{y}$
\end_inset
.
In that case, the term
\begin_inset Formula $\boldsymbol{y}^{T}\boldsymbol{y}$
\end_inset
is a constant.
Effectively we have to minimize
\begin_inset Formula
\begin{equation}
\frac{1}{2}\boldsymbol{f}^{T}A\boldsymbol{f-}\boldsymbol{b}^{T}\boldsymbol{f}
\end{equation}
\end_inset
with
\begin_inset Formula
\begin{equation}
A=\Phi\Phi^{T},\quad\boldsymbol{b}=\Phi\boldsymbol{y}.
\end{equation}
\end_inset
This is equivalent to solving the linear system
\begin_inset Formula
\begin{equation}
A\boldsymbol{f}=\boldsymbol{b}.
\end{equation}
\end_inset
In contrast to the collocation case, the matrix
\begin_inset Formula $A$
\end_inset
is nicely symmetric.
We will now generalize this result to a setting where data can have random
noise.
\end_layout
\begin_layout Subsection
Basics on probability theory
\end_layout
\begin_layout Standard
Here we treat probability in a Bayesian sense.
The philosophical difference to
\begin_inset Quotes eld
\end_inset
orthodox
\begin_inset Quotes erd
\end_inset
statistics is, that we probability is seen as a measure of uncertainty
here, rather than being linked to something that occurs by chance.
In particular we say how probable it is that a model, or a set of model
parameters are the correct ones.
For this purpose we make use of Bayes' rule.
Keep in mind that this rule exists in all variants and interpretations
of probability theory and statistics, as the underlying math is the same.
The difference is only how far we go to assign probabilities.
\end_layout
\begin_layout Subsection*
Updating knowledge via Bayes' rule
\end_layout
\begin_layout Standard
The probability that
\begin_inset Formula $a$
\end_inset
AND
\begin_inset Formula $b$
\end_inset
happened can be written in two ways.
Example: we compute the probability that someone is rich and beautiful
either by taking the probability that someone is rich times the probability
that a rich person is beautiful, or the other way round:
\begin_inset Formula
\begin{equation}
p(a\wedge b)=p(a|b)p(b)=p(b|a)p(a).
\end{equation}
\end_inset
Here
\begin_inset Formula $p(a|b)$
\end_inset
means the probability for
\begin_inset Formula $a$
\end_inset
under the condition that
\begin_inset Formula $b$
\end_inset
is given.
In case
\begin_inset Formula $p(b)\neq0$
\end_inset
, we deduce Bayes' rule
\begin_inset Formula
\begin{equation}
p(a|b)=\frac{p(b|a)p(a)}{p(b)}.
\end{equation}
\end_inset
In our application,
\begin_inset Formula $a=w$
\end_inset
are model parameters (
\begin_inset Quotes eld
\end_inset
weights
\begin_inset Quotes erd
\end_inset
) and/or hyperparameters (we call them
\begin_inset Formula $\theta$
\end_inset
later) whose distribution we want to know, and
\begin_inset Formula $b=y$
\end_inset
are measured data.
It is usually easy to write
\begin_inset Formula $p(y|w)$
\end_inset
for a given model, but what we want to know in the end is
\begin_inset Formula $p(w|y)$
\end_inset
, so how probable it is that our model is correctly parametrized.
Terms in the expression
\begin_inset Formula
\begin{equation}
p(w|y)=\frac{p(y|w)p(w)}{p(y)}
\end{equation}
\end_inset
are called
\end_layout
\begin_layout Itemize
\emph on
Posterior
\series bold
\begin_inset Formula $p(w|y)$
\end_inset
\series default
\emph default
: Probability of parameters that we want to know or maximize.
\end_layout
\begin_layout Itemize
\emph on
Likelihood
\series bold
\begin_inset Formula $p(y|w)$
\end_inset
\series default
\emph default
: How likely it is to measure
\begin_inset Formula $y$
\end_inset
assuming a model with fixed
\begin_inset Formula $w$
\end_inset
.
\end_layout
\begin_layout Itemize
\emph on
Prior
\series bold
\begin_inset Formula $p(w)$
\end_inset
\series default
\emph default
: Distribution of meaningful values of
\begin_inset Formula $w$
\end_inset
without knowing any data.
\end_layout
\begin_layout Itemize
\emph on
Evidence
\emph default
\begin_inset Formula $p(y)$
\end_inset
: Normalization factor to make
\begin_inset Formula $\int p(w|y)dw=1$
\end_inset
(only needed for more advanced stuff).
\end_layout
\begin_layout Subsection
Linear regression
\end_layout
\begin_layout Standard
(See also R&W chapter 2) Linear regression allows for random noise in the
input data.
We assume measurements of a function
\begin_inset Formula $f$
\end_inset
with some constant (homoscedastic) error term
\begin_inset Formula
\begin{equation}
y=f(\boldsymbol{x})+\varepsilon
\end{equation}
\end_inset
where
\begin_inset Formula
\begin{equation}
\varepsilon\sim\mathcal{N}(0,\sigma_{n}^{\,2})
\end{equation}
\end_inset
is Gaussian noise with (a priori unknown) variance
\begin_inset Formula $\sigma_{n}^{2}$
\end_inset
.
More generally speaking we denote quantities such as
\begin_inset Formula $y$
\end_inset
as
\emph on
random variables
\emph default
.
Functions of random variables give new random variables.
Linear functions applied to Gaussian random variables like
\begin_inset Formula $y$
\end_inset
give Gaussian random variables.
We use a
\emph on
linear model
\emph default
\begin_inset Formula
\begin{equation}
f(\mathbf{x})=\sum_{k}w_{k}\phi_{k}(\mathbf{x})=\mathbf{w}^{T}\boldsymbol{\phi}(\mathbf{x}).
\end{equation}
\end_inset
\end_layout
\begin_layout Standard
We make some (noisy, if
\begin_inset Formula $\sigma_{n}>0$
\end_inset
) observations of a
\emph on
realization
\emph default
\begin_inset Formula $\mathbf{y}=(y_{1},y_{2},\dots y_{n})$
\end_inset
at training points
\begin_inset Formula $X=(\mathbf{x}_{1},\mathbf{x}_{2},\dots,\mathbf{x}_{n})$
\end_inset
.
We sloppily call the realizations also
\begin_inset Formula $y$
\end_inset
, but in more precise terms we should use another letter to distinguish
them from the random variable for which we can draw an infinite number
of different realizations with random outcome.
Say we observed
\begin_inset Formula
\begin{equation}
y_{i}=\sum_{k}w_{k}\phi_{k}(\mathbf{x}_{i})+\varepsilon.
\end{equation}
\end_inset
In a vectorial way one would write
\begin_inset Formula
\begin{equation}
\mathbf{y}=\mathbf{w}^{T}\Phi(X)+\boldsymbol{\varepsilon}.
\end{equation}
\end_inset
Then the distribution of the data
\begin_inset Formula $\mathbf{y}$
\end_inset
with given weights is a multivariate normal distribution
\begin_inset Formula
\begin{equation}
p(\mathbf{y}|X,\mathbf{w})=\mathcal{N}(\mathbf{w}^{T}\Phi(X),\sigma_{n}^{\,2}I).
\end{equation}
\end_inset
In addition, we need a prior that we choose as
\begin_inset Formula
\begin{equation}
p(\mathbf{w})=\mathcal{N}(0,\Sigma_{p}).
\end{equation}
\end_inset
If
\begin_inset Formula $\Sigma_{p}$
\end_inset
is a diagonal, its entries
\begin_inset Formula $\Sigma_{p,ii}$
\end_inset
just mean how important we think that the contribution of the
\begin_inset Formula $i$
\end_inset
-th basis function is.
In an infinite functional basis this should decay to zero at some point.
Bayes' rule gives
\begin_inset Formula
\begin{align}
p(\boldsymbol{w}|X,\boldsymbol{y}) & =\frac{p(\mathbf{y}|X,\mathbf{w})p(\mathbf{w})}{p(\mathbf{y})}\\
& =FAC\frac{\exp\left(-\frac{(\mathbf{y}-\mathbf{w}^{T}\Phi)^{2}}{2\sigma_{n}^{\,2}}\right)\exp\left(-\frac{1}{2}\mathbf{w}^{T}\Sigma_{p}^{-1}\mathbf{w}\right)}{p(\mathbf{y})}\\
& =\frac{FAC}{p(\mathbf{y})}\exp\left(-\frac{1}{2\sigma_{n}^{\,2}}\left((\mathbf{y}-\mathbf{w}^{T}\Phi)^{2}+\sigma_{n}^{\,2}\mathbf{w}^{T}\Sigma_{p}^{-1}\mathbf{w}\right)\right)\\
& =\frac{FAC}{p(\mathbf{y})}\exp\left(-\frac{1}{2\sigma_{n}^{\,2}}\left(\mathbf{y}^{2}-2\mathbf{y}^{T}\mathbf{w}^{T}\Phi+\mathbf{w}^{T}\Phi\Phi^{T}\mathbf{w}+\sigma_{n}^{\,2}\mathbf{w}^{T}\Sigma_{p}^{-1}\mathbf{w}\right)\right)\\
& =\frac{FAC}{p(\mathbf{y})}\exp\left(-\frac{1}{2\sigma_{n}^{\,2}}\left(\mathbf{y}^{2}-2\mathbf{y}^{T}\mathbf{w}^{T}\Phi+\mathbf{w}^{T}(\underbrace{\Phi\Phi^{T}+\sigma_{n}^{\,2}\Sigma_{p}^{-1}}_{A})\mathbf{w}\right)\right)
\end{align}
\end_inset
TODO
\end_layout
\begin_layout Standard
Then we can find the posterior after observation of (possibly noisy) training