-
Notifications
You must be signed in to change notification settings - Fork 0
/
PointProcessSSGLM-development.lyx
2955 lines (2133 loc) · 66.6 KB
/
PointProcessSSGLM-development.lyx
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.1 created this file. For more info see http://www.lyx.org/
\lyxformat 474
\begin_document
\begin_header
\textclass article
\begin_preamble
\setcounter{section}{0}
\numberwithin{equation}{section}
\end_preamble
\use_default_options true
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry true
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 0
\use_package esint 1
\use_package mathdots 0
\use_package mathtools 0
\use_package mhchem 1
\use_package stackrel 0
\use_package stmaryrd 0
\use_package undertilde 0
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 0
\index Index
\shortcut idx
\color #008000
\end_index
\leftmargin 1cm
\rightmargin 1cm
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\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 Section
Development of the point-process filtering and SS-GLM
\end_layout
\begin_layout Subsection
The CIF (rate function)
\end_layout
\begin_layout Standard
We examine the spike trains that a neuron elicits in all the trials in the
experiment and built a raster plot.
In a steady state, we could simply average in each time bin and get a PSTH.
When learning occurs this is impossible.
Instead we define a rate function (single trial
\begin_inset Quotes eld
\end_inset
PSTH
\begin_inset Quotes erd
\end_inset
) for trial #k and time bin #l of size
\begin_inset Formula $\Delta$
\end_inset
:
\end_layout
\begin_layout Standard
\begin_inset Formula
\begin{equation}
\lambda_{k}\left(l|\theta_{k},\gamma,H_{k}\right)=\exp\left\{ \sum_{r=1}^{R}\theta_{k,r}g_{,r}\left(l\right)\right\} \exp\left\{ \sum_{j=1}^{l}\gamma_{j}n_{k,l-j}\right\}
\end{equation}
\end_inset
\end_layout
\begin_layout Standard
Where:
\end_layout
\begin_layout Standard
\begin_inset Formula $\theta_{k}$
\end_inset
is a vector of the
\begin_inset Quotes eld
\end_inset
PSTH
\begin_inset Quotes erd
\end_inset
in trial #k
\end_layout
\begin_layout Standard
\begin_inset Formula $g_{r}\left(l\right)=\begin{cases}
\begin{array}{c}
1\\
0
\end{array} & \begin{array}{c}
\left(r-1\right)\cdot\frac{T}{R}<l\le r\cdot\frac{T}{R}\\
otherwise
\end{array}\end{cases}$
\end_inset
,
\begin_inset Formula $T$
\end_inset
being the number of bins in each trial (each bin of duration
\begin_inset Formula $\Delta$
\end_inset
typically 1mSec) and
\begin_inset Formula $R$
\end_inset
being the number of PSTH bins.
\end_layout
\begin_layout Standard
\begin_inset Formula $\gamma$
\end_inset
is a vector of the self - history dependence
\end_layout
\begin_layout Standard
\begin_inset Formula $H_{k}$
\end_inset
is the history (of spiking) and in our case it is the binary vector
\begin_inset Formula $n_{k}$
\end_inset
.
\end_layout
\begin_layout Subsection
The log-likelihood function
\end_layout
\begin_layout Standard
The probability of observing
\begin_inset Formula $n_{k}$
\end_inset
spikes in trial #k and time bin #l is simply
\begin_inset Formula $p\left(N_{k}\left(l\right)=n_{k}\left(l\right)\right)=\left(\lambda_{k}\left(l\right)\cdot\Delta\right)^{n_{k}\left(l\right)}\cdot\left(1-\lambda_{k}\left(l\right)\cdot\Delta\right)^{1-n_{k}\left(l\right)}\approx\frac{\left(\lambda_{k}\left(l\right)\Delta\right)^{n_{k}\left(l\right)}\cdot\exp\left(-\lambda_{k}\left(l\right)\Delta\right)}{n_{k}\left(l\right)!}$
\end_inset
.
The Poisson approximation is valid for
\begin_inset Formula $n_{k}=0,1$
\end_inset
and
\begin_inset Formula $\lambda\Delta\ll1$
\end_inset
.
Thus, the log-likelihood of a single time bin is:
\end_layout
\begin_layout Standard
\begin_inset Formula
\[
\log p\left(N_{k}\left(l\right)=n_{k}\left(l\right)\right)=-\lambda_{k}\left(l\right)\Delta+n_{k}\left(l\right)\cdot\log\left(\lambda_{k}\left(l\right)\Delta\right)
\]
\end_inset
\end_layout
\begin_layout Standard
We assume that the trial by trial evolution of the PSTH parameters follow
a gaussian distribution.
Namely,
\begin_inset Formula
\begin{equation}
p\left(\theta_{k+1}|\theta_{k}\right)\sim\mathbb{N}\left(0,\Sigma\right)
\end{equation}
\end_inset
\end_layout
\begin_layout Standard
At this point the mean is zero and we still didn't take stimulus features
into account.
A non-zero mean will be added in section 7 as a result of a fitted learning
algorithm.
Stimulus features are added in section 6.
\end_layout
\begin_layout Standard
If we assign the symbol
\begin_inset Formula $\theta_{0}$
\end_inset
to the initial value of
\begin_inset Formula $\theta$
\end_inset
we can get the log-likelihood function of the observed spikes (
\begin_inset Formula $\left\{ N_{k}\right\} _{k=1}^{K}$
\end_inset
) and the hidden process
\family roman
\series medium
\shape up
\size normal
\emph off
\bar no
\noun off
\color none
(
\begin_inset Formula $\left\{ \theta_{k}\right\} _{k=1}^{K}$
\end_inset
)
\family default
\series default
\shape default
\size default
\emph default
\bar default
\noun default
\color inherit
as a sum over all time bins in all trials:
\end_layout
\begin_layout Standard
\begin_inset Formula
\[
L=\log p\left(\left\{ N_{k}\right\} _{k=1}^{K},\left\{ \theta_{k}\right\} _{k=1}^{K}|\psi\right)=\log\sum_{k=1}^{K}p\left(\mathbf{n_{k}}|\theta_{k},H_{k}\right)\cdot p\left(\theta_{k}|\theta_{k-1}\right)=
\]
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Formula
\begin{equation}
=\sum_{k=1}^{K}\sum_{l=1}^{T}\left[-\lambda_{k}\left(l\right)\Delta+n_{k}\left(l\right)\cdot\log\left(\lambda_{k}\left(l\right)\Delta\right)\right]+K\cdot\log\left(\left(2\pi\right)^{-\frac{R}{2}}\cdot\left|\Sigma\right|^{-\frac{1}{2}}\right)-\frac{1}{2}\left(\theta_{k}-\theta_{k-1}\right)^{T}\Sigma^{-1}\left(\theta_{k}-\theta_{k-1}\right)
\end{equation}
\end_inset
\end_layout
\begin_layout Standard
Our log-likelihood function is
\begin_inset Formula $F\left(\psi\right)=\log\int d^{K}\theta e^{L}$
\end_inset
.
\end_layout
\begin_layout Standard
The parameters of the likelihood function are
\begin_inset Formula $\psi=\left(\gamma,\theta_{0},\Sigma\right)$
\end_inset
and maximizing the likelihood can be done in the gradient ascent / simulated
annealing methods.
\end_layout
\begin_layout Standard
In our optimizations we will assume
\begin_inset Formula $\Sigma$
\end_inset
to be diagonal (block diagonal after introducing the features) and next
we introduce the EM algorithm for likelihood maximization.
\end_layout
\begin_layout Subsection
The EM algorithm (introduction)
\end_layout
\begin_layout Subsubsection
Formulation
\end_layout
\begin_layout Standard
We're looking for the set of parameters,
\begin_inset Formula $\psi^{*}$
\end_inset
that maximizes
\begin_inset Formula $F\left(\psi\right)=\log\int p\left(\left\{ N_{k}\right\} _{k=1}^{K},\left\{ \theta_{k}\right\} _{k=1}^{K}|\psi\right)d^{K}\theta$
\end_inset
.
Assume the existance of an auxillary function
\begin_inset Formula $Q\left(\psi,\psi'\right)$
\end_inset
that satisfies the following:
\end_layout
\begin_layout Itemize
\begin_inset Formula $Q\left(\psi,\psi'\right)\le F\left(\psi\right)\forall\psi'$
\end_inset
\end_layout
\begin_layout Itemize
\begin_inset Formula $F\left(\psi\right)=Q\left(\psi,\psi\right)$
\end_inset
\end_layout
\begin_layout Standard
This means that we can define an iterative process that maximizes the log-likeli
hood (locally).
At step 'i' we define
\begin_inset Formula $\psi^{\left(i+1\right)}=\arg\max_{\psi}Q\left(\psi,\psi^{\left(i\right)}\right)$
\end_inset
.
This choice means that
\end_layout
\begin_layout Standard
\begin_inset Formula
\[
F\left(\psi^{\left(i+1\right)}\right)=Q\left(\psi^{\left(i+1\right)},\psi^{\left(i+1\right)}\right)\ge Q\left(\psi^{\left(i+1\right)},\psi^{\left(i\right)}\right)\ge Q\left(\psi^{\left(i\right)},\psi^{\left(i\right)}\right)=F\left(\psi^{\left(i\right)}\right)
\]
\end_inset
\end_layout
\begin_layout Standard
This form suggest a two stage iterative algorithm.
It is named EM-algorithm (the 'expectation' nature of the first step will
become clear later in this section) and at step 'i' it goes as:
\end_layout
\begin_layout Itemize
E-Step: Calculate
\begin_inset Formula $Q\left(\psi,\psi^{\left(i\right)}\right)$
\end_inset
.
\end_layout
\begin_layout Itemize
M-Step: find
\begin_inset Formula $\psi^{\left(i+1\right)}$
\end_inset
by maximizing
\begin_inset Formula $\psi^{\left(i+1\right)}=\arg\max_{\psi}Q\left(\psi,\psi^{\left(i\right)}\right)$
\end_inset
.
\end_layout
\begin_layout Standard
Using the notation of
\begin_inset Formula $N,\theta$
\end_inset
to describe the observable and latent variables we find
\begin_inset Formula $Q$
\end_inset
in the following way:
\end_layout
\begin_layout Standard
\begin_inset Formula
\[
F\left(\psi\right)\overset{1}{=}F\left(\psi'\right)+\log\frac{p\left(N|\psi\right)}{p\left(N|\psi'\right)}\overset{2}{=}F\left(\psi'\right)+\log\int p\left(\theta|N,\psi'\right)\frac{p\left(\theta|N,\psi\right)}{p\left(\theta|N,\psi'\right)}\cdot\frac{p\left(N|\psi\right)}{p\left(N|\psi'\right)}d^{K}\theta
\]
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Formula
\[
\overset{3}{=}F\left(\psi'\right)+\log\int p\left(\theta|N,\psi'\right)\frac{p\left(N,\theta|\psi\right)}{p\left(N,\theta|\psi'\right)}d^{K}\theta\overset{4}{\ge}F\left(\psi'\right)+\int p\left(\theta|N,\psi'\right)\log\frac{p\left(N,\theta|\psi\right)}{p\left(N,\theta|\psi'\right)}d^{K}\theta
\]
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Formula
\[
\equiv Q\left(\psi,\psi'\right)
\]
\end_inset
\end_layout
\begin_layout Standard
Where:
\end_layout
\begin_layout Enumerate
From the definition of
\begin_inset Formula $F\left(\psi\right)=\log p\left(\left\{ N_{k}\right\} _{k=1}^{K}|\psi\right)$
\end_inset
\end_layout
\begin_layout Enumerate
Because
\begin_inset Formula $\int p\left(\theta|N,\psi'\right)\frac{p\left(\theta|N,\psi\right)}{p\left(\theta|N,\psi'\right)}d^{K}\theta=1$
\end_inset
\end_layout
\begin_layout Enumerate
From Bayes' law
\begin_inset Formula $p\left(\theta|N,\psi\right)\cdot p\left(N|\psi\right)=p\left(N,\theta|\psi\right)$
\end_inset
\end_layout
\begin_layout Enumerate
From Jensen's inequality:
\begin_inset Formula $\log\int\ge\int\log$
\end_inset
in concave functions (log of the mean vs.
mean of log)
\end_layout
\begin_layout Standard
Note that
\begin_inset Formula $Q\left(\psi,\psi'\right)=F\left(\psi'\right)-\frac{1}{p\left(N|\psi'\right)}D_{KL}\left[p\left(N,\theta|\psi'\right)||p\left(N,\theta|\psi\right)\right]$
\end_inset
which means that the requirements above are met.
In applying the E-step it is enough to reduce the auxillary function to
\end_layout
\begin_layout Standard
\begin_inset Formula
\begin{equation}
Q\left(\psi,\psi'\right)=\int p\left(\theta|N,\psi'\right)\log p\left(N,\theta|\psi\right)d^{K}\theta=E_{p\left(\theta|N,\psi'\right)}L\label{eq:1.4}
\end{equation}
\end_inset
\end_layout
\begin_layout Standard
Because the M-step requires optimization over
\begin_inset Formula $\psi$
\end_inset
and not
\begin_inset Formula $\psi'$
\end_inset
.
Now this is in the form of an expected value ...Hence the 'E-Step'.
\end_layout
\begin_layout Subsubsection
Remarks
\end_layout
\begin_layout Standard
Note two important points:
\end_layout
\begin_layout Enumerate
We never actually compute the log-likelihood
\begin_inset Formula $F\left(\psi\right)$
\end_inset
.
\end_layout
\begin_layout Enumerate
We get the divergence 'for free' because:
\begin_inset Formula $\nabla_{\psi}\log p\left(N|\psi\right)|_{\psi=\psi'}=\nabla_{\psi}\log\int p\left(N,\theta|\psi\right)d^{K}\theta|_{\psi=\psi'}=\frac{1}{p\left(N|\psi'\right)}\cdot\nabla_{\psi}\int p\left(N,\theta|\psi\right)d^{K}\theta|_{\psi=\psi'}=\int\frac{p\left(N,\theta|\psi'\right)}{p\left(N|\psi'\right)}\cdot\nabla_{\psi}\log p\left(N,\theta|\psi\right)d^{K}\theta|_{\psi=\psi'}=\nabla_{\psi}Q\left(\psi,\psi'\right)|_{\psi=\psi'}$
\end_inset
\end_layout
\begin_layout Subsection
E-Step - i'th iteration
\end_layout
\begin_layout Standard
Here we need to compute the expectation of
\begin_inset Formula $L$
\end_inset
(eqn
\begin_inset CommandInset ref
LatexCommand ref
reference "eq:1.4"
\end_inset
) over the distribution
\begin_inset Formula $p\left(\theta|N,\psi'\right)$
\end_inset
.
This calculation boils down to computing the following constituents:
\end_layout
\begin_layout Enumerate
\begin_inset Formula $\theta_{k|K}\equiv\int p\left(\theta|N,\psi'\right)\cdot\theta_{k}d^{K}\theta$
\end_inset
\end_layout
\begin_layout Enumerate
\begin_inset Formula $W_{k,k+1|K}\equiv\int p\left(\theta|N,\psi'\right)\cdot\left(\theta_{k}-\theta_{k|K}\right)\cdot\left(\theta_{k+1}-\theta_{k+1|K}\right)d^{K}\theta$
\end_inset
which is the covariance of
\begin_inset Formula $\theta_{k},\theta_{k+1}$
\end_inset
\end_layout
\begin_layout Enumerate
\family roman
\series medium
\shape up
\size normal
\emph off
\bar no
\noun off
\color none
\begin_inset Formula $\int p\left(\theta|N,\psi'\right)\cdot\theta_{k}^{2}d^{K}\theta$
\end_inset
\end_layout
\begin_layout Enumerate
\family roman
\series medium
\shape up
\size normal
\emph off
\bar no
\noun off
\color none
\begin_inset Formula $\int p\left(\theta|N,\psi'\right)\cdot\exp\left(\theta_{k}\right)d^{K}\theta$
\end_inset
\end_layout
\begin_layout Standard
The whole point here is going to be that we assume the distribution of
\begin_inset Formula $\theta_{0}$
\end_inset
to be Gaussian (or a
\begin_inset Formula $\delta$
\end_inset
function) and that all posterior distributions (
\begin_inset Formula $p\left(\theta_{k}|...\right)$
\end_inset
) are also Gaussian.
This will allow developing a filtering algorithm.
\end_layout
\begin_layout Standard
This is done by several algorithms:
\end_layout
\begin_layout Subsubsection
Forward filter algorithm (Kalman++ Eden et al 2004)
\end_layout
\begin_layout Standard
Define the following mean values and covariance matrices:
\end_layout
\begin_layout Enumerate
\begin_inset Formula $\theta_{k|k-1}=E\left[\theta_{k}|N_{1:k-1},\psi^{(i)}\right]$
\end_inset
\end_layout
\begin_layout Enumerate
\begin_inset Formula $\theta_{k|k}=E\left[\theta_{k}|N_{1:k},\psi^{(i)}\right]$
\end_inset
includes the spiking activity in the k'th trial
\end_layout
\begin_layout Enumerate
\begin_inset Formula $W_{k|k-1}=Var\left[\theta_{k}|N_{1:k-1},\psi^{(i)}\right]$
\end_inset
\end_layout
\begin_layout Enumerate
\family roman
\series medium
\shape up
\size normal
\emph off
\bar no
\noun off
\color none
\begin_inset Formula $W_{k|k}=Var\left[\theta_{k}|N_{1:k},\psi^{(i)}\right]$
\end_inset
\end_layout
\begin_layout Standard
This algorithm starts from the initial values
\begin_inset Formula $\theta_{1|0}=\theta_{0}$
\end_inset
and
\begin_inset Formula $W_{0|0}=0$
\end_inset
and iterates forward the following steps:
\end_layout
\begin_layout Subparagraph
One step prediction:
\end_layout
\begin_layout Standard
From the identity
\begin_inset Formula $p\left(\theta_{k}|N_{1:k-1},\psi^{(i)}\right)=\int p\left(\theta_{k}|\theta_{k-1},\psi^{(i)}\right)p\left(\theta_{k-1}|N_{1:k-1},\psi^{(i)}\right)d\theta_{k-1}$
\end_inset
we assume all densities to be Gaussian;
\begin_inset Formula $p\left(\theta_{k}|N_{1:k-1},\psi^{(i)}\right)\sim N\left(\theta_{k|k-1},W_{k|k-1}\right)$
\end_inset
,
\begin_inset Formula $p\left(\theta_{k-1}|N_{1:k-1},\psi^{(i)}\right)\sim N\left(\theta_{k-1|k-1},W_{k-1|k-1}\right)$
\end_inset
and
\begin_inset Formula $p\left(\theta_{k}|\theta_{k-1},\psi^{(i)}\right)\sim N\left(\theta_{k-1},\Sigma\right)$
\end_inset
.
The convolution of two gaussians is also a gaussian (Appendix) so we immediatel
y get the relation:
\begin_inset Formula
\begin{equation}
\theta_{k|k-1}=\theta_{k-1|k-1},W_{k|k-1}=W_{k-1|k-1}+\Sigma
\end{equation}
\end_inset
\end_layout
\begin_layout Standard
Next, we incorporate the observed spikes in the k'th trial.
\end_layout
\begin_layout Subparagraph
The posterior distribution:
\end_layout
\begin_layout Standard
We use Bayes law to incorporate the observed spikes in the k'th trial:
\begin_inset Formula $p\left(\theta_{k}|N_{1:k},\psi^{(i)}\right)\overset{1}{=}\frac{p\left(N_{1:k}|\theta_{k},\psi^{(i)}\right)\cdot p\left(\theta_{k}|\psi^{(i)}\right)}{p\left(N_{1:k}\right)}\overset{2}{=}\frac{p\left(N_{k}|\theta_{k},\psi^{(i)}\right)\cdot p\left(N_{1:k-1}|\theta_{k},\psi^{(i)}\right)\cdot p\left(\theta_{k}|\psi^{(i)}\right)}{p\left(N_{k}|N_{1:k-1}\right)\cdot p\left(N_{1:k-1}\right)}$
\end_inset
\begin_inset Formula $\overset{3}{=}\frac{p\left(N_{k}|\theta_{k},\psi^{(i)}\right)\cdot p\left(N_{1:k-1}\right)\cdot p\left(\theta_{k}|N_{1:k-1},\psi^{(i)}\right)}{p\left(N_{k}|N_{1:k-1}\right)\cdot p\left(N_{1:k-1}\right)}$
\end_inset
\begin_inset Formula $\overset{4}{=}\frac{p\left(N_{k}|\theta_{k},\psi^{(i)}\right)\cdot p\left(\theta_{k}|N_{1:k-1},\psi^{(i)}\right)}{p\left(N_{k}|N_{1:k-l},\psi^{(i)}\right)}\sim N\left(\theta_{k|k},W_{k|k}\right)$
\end_inset
.
Where (1) and (3) follow Bayes' rule, (2) stems from
\begin_inset Formula $N_{k}$
\end_inset
and
\begin_inset Formula $N_{1:k-1}$
\end_inset
being independent given
\begin_inset Formula $\theta_{k}$
\end_inset
and (4) is simple algebra.
\end_layout
\begin_layout Standard
We are going to take the log of both sides and differentiate with respect
to
\begin_inset Formula $\theta_{k}$
\end_inset
so we can ignore the denominator.
\end_layout
\begin_layout Standard
We use
\begin_inset Formula $p\left(N_{k}|\theta_{k},\psi^{(i)}\right)=\prod_{l}\exp\left[-\lambda_{k}\left(l\right)\Delta+n_{k}\left(l\right)\cdot\log\left(\lambda_{k}\left(l\right)\Delta\right)\right]$
\end_inset
and
\begin_inset Formula $p\left(\theta_{k}|N_{1:k-1},\psi^{(i)}\right)\sim N\left(\theta_{k|k-1},W_{k|k-1}\right)$
\end_inset
to get
\end_layout
\begin_layout Standard
\begin_inset Formula
\begin{equation}
-\frac{1}{2}\left(\theta_{k}-\theta_{k|k}\right)^{T}W_{k|k}^{-1}\left(\theta_{k}-\theta_{k|k}\right)=\sum_{l=1}^{T}\left[-\lambda_{k}\left(l\right)\Delta+n_{k}\left(l\right)\cdot\log\left(\lambda_{k}\left(l\right)\Delta\right)\right]-\frac{1}{2}\left(\theta_{k}-\theta_{k|k-1}\right)^{T}W_{k|k-1}^{-1}\left(\theta_{k}-\theta_{k|k-1}\right)+constants
\end{equation}
\end_inset
\end_layout
\begin_layout Standard
We now derivate with respect to
\begin_inset Formula $\theta_{k}$
\end_inset
twice.
First to get the linear term (the mean) and second to get the variance.
(remember that
\begin_inset Formula $W$
\end_inset
and
\begin_inset Formula $W^{-1}$
\end_inset
are symmetric)
\end_layout
\begin_layout Standard
\begin_inset Formula
\[
\frac{\partial}{\partial\theta_{k,r}}\rightarrow\left[W_{k|k}^{-1}\cdot\left(\theta_{k}-\theta_{k|k}\right)\right]_{r}=\left[W_{k|k-1}^{-1}\cdot\left(\theta_{k}-\theta_{k|k-1}\right)\right]_{r}-\sum_{l=1}^{T}\frac{\partial\log\left(\lambda_{k}\left(l\right)\right)}{\partial\theta_{k,r}}\cdot\left[n_{k}\left(l\right)-\lambda_{k}\left(l\right)\Delta\right]
\]
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Formula
\begin{equation}
=\left[W_{k|k-1}^{-1}\cdot\left(\theta_{k}-\theta_{k|k-1}\right)\right]_{r}-\sum_{l=\left(r-1\right)\frac{T}{R}}^{r\frac{T}{R}}\left[n_{k}\left(l\right)-\lambda_{k}\left(l\right)\Delta\right]
\end{equation}
\end_inset
\end_layout
\begin_layout Standard
This should hold for
\begin_inset Formula $\theta_{k}=\theta_{k|k-1}$
\end_inset
so we insert it and get
\end_layout
\begin_layout Standard
\begin_inset Formula
\begin{equation}
-W_{k|k}^{-1}\cdot\left(\theta_{k|k-1}-\theta_{k|k}\right)=\sum_{l=1}^{T}\frac{\partial\log\left(\lambda_{k}\left(l\right)\right)}{\partial\theta}\cdot\left[n_{k}\left(l\right)-\lambda_{k}\left(l\right)\Delta\right]|_{\theta=\theta_{k|k-1}}
\end{equation}
\end_inset
\end_layout
\begin_layout Standard
which we solve and get:
\end_layout
\begin_layout Standard
\begin_inset Formula
\begin{equation}
\theta_{k|k}=\theta_{k|k-1}+W_{k|k}\cdot\sum_{l=1}^{T}\frac{\partial\log\left(\lambda_{k}\left(l\right)\right)}{\partial\theta_{k}}\cdot\left[n_{k}\left(l\right)-\lambda_{k}\left(l\right)\Delta\right]=\theta_{k|k-1}+W_{k|k}\cdot\left(\begin{array}{c}
\sum_{l=1}^{\frac{T}{R}}\left(n_{k}\left(l\right)-\lambda_{k}\left(l\right)\cdot\Delta\right)\\
.\\
.\\
\sum_{l=T\cdot\frac{R-1}{R}+1}^{T}\left(n_{k}\left(l\right)-\lambda_{k}\left(l\right)\cdot\Delta\right)
\end{array}\right)|_{\theta=\theta_{k|k-1}}
\end{equation}
\end_inset
\end_layout
\begin_layout Standard
We now differentiate again:
\end_layout
\begin_layout Standard
\begin_inset Formula
\[
\frac{\partial}{\partial\theta_{k}}\left\{ W_{k|k}^{-1}\cdot\left(\theta_{k}-\theta_{k|k}\right)=W_{k|k-1}^{-1}\cdot\left(\theta_{k}-\theta_{k|k-1}\right)-\sum_{l=1}^{T}\frac{\partial\log\left(\lambda_{k}\left(l\right)\right)}{\partial\theta_{k}}\cdot\left[n_{k}\left(l\right)-\lambda_{k}\left(l\right)\Delta\right]\right\}
\]
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Formula
\[
W_{k|k}^{-1}=W_{k|k-1}^{-1}-\sum_{l=1}^{T}\left\{ \frac{\partial^{2}\log\left(\lambda_{k}\left(l\right)\right)}{\partial\theta^{2}}\cdot\left[n_{k}\left(l\right)-\lambda_{k}\left(l\right)\Delta\right]-\Delta\lambda_{k}\left(l\right)\cdot\frac{\partial\log\left(\lambda_{k}\left(l\right)\right)}{\partial\theta}\cdot\left(\frac{\partial\log\left(\lambda_{k}\left(l\right)\right)}{\partial\theta}\right)^{T}\right\} |_{\theta=\theta_{k|k-1}}
\]
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Formula
\begin{equation}
\left[W_{k|k}^{-1}\right]_{ab}=\left[W_{k|k-1}^{-1}\right]_{ab}+\Delta\cdot\delta_{ab}\sum_{l=\left(a-1\right)\frac{T}{R}+1}^{a\frac{T}{R}}\lambda_{k}\left(l\right)\cdot|_{\theta=\theta_{k|k-1}}
\end{equation}
\end_inset
\end_layout
\begin_layout Standard
This is the first order (in
\begin_inset Formula $\Delta$
\end_inset
) correction to the Kalman filter for non-Gaussian observation.
\end_layout
\begin_layout Standard
So, we starts sequentially (in 'k'), from equation # followed by equations
#,# and calculate
\begin_inset Formula $\theta_{k|k},W_{k|k}$
\end_inset
.
\end_layout
\begin_layout Subparagraph
Note:
\end_layout
\begin_layout Standard
There is a point here that is not clear.
In deriving the last equation (#) we insert
\begin_inset Formula $\theta=\theta_{k|k-1}$
\end_inset
but this is arbitrary.
The correction to
\begin_inset Formula $W_{k|k}$
\end_inset
is
\begin_inset Formula $\theta$
\end_inset
dependent which seems wrong to me.
\end_layout
\begin_layout Standard
(It will also be the same result if we develop
\begin_inset Formula $\lambda_{k}$
\end_inset
around
\begin_inset Formula $\theta_{k|k-1}$
\end_inset
...
so it's fine)
\end_layout
\begin_layout Subsubsection
Smoothing algorithm (Kalman smoother)
\end_layout
\begin_layout Standard
This is a reverse sequence a.k.a.
the Kalman smoother (Jazwinski, page 217, equation 7.86, see also in Shumway
and Stoffer 1982)
\end_layout
\begin_layout Standard
This is developed here for
\begin_inset Formula $\theta_{k+1}-\theta_{k}\sim N\left(0,\Sigma\right)$
\end_inset
and assumes that we have
\begin_inset Formula $\theta_{k|k},W_{k|k}\forall k$
\end_inset
(from previous stages).
This algorithm will have to be revisited when introducing learning algorithms
in section 7.
\end_layout
\begin_layout Standard