Transcript Slide 1

580.691 Learning Theory
Reza Shadmehr
State estimation theory
A
B
Subject was instructed to pull on a knob that was fixed on a rigid wall. A) EMG recordings from arm and leg muscles.
Before biceps is activated, the brain activates the leg muscles to stabilize the lower body and prevent sway due to the
anticipated pulling force on the upper body. B) When a rigid bar is placed on the upper body, the leg muscles are not
activated when biceps is activated. (Cordo and Nashner, 1982)
B
100 Hz
A
Effect of eye movement on the memory of a visual stimulus. In the top panel, the filled circle represents the fixation
point, the asterisk indicates the location of the visual stimulus, and the dashed circle indicates the receptive field a cell
in the LIP region of the parietal cortex. A) Discharge to the onset and offset of a visual stimulus in the cell’s receptive
field. Abbreviations: H. eye, horizontal eye position; Stim, stimulus; V. eye, vertical eye position. B) Discharge during
the time period in which a saccade brings the stimulus into the cell’s receptive field. The cell’s discharge increased
before the saccade brought the stimulus into the cell’s receptive field. (From (Duhamel et al., 1992)
Why predict sensory consequences of motor commands?
Subject looked at a moving cursor while a group of dots appeared on the screen for 300ms. In some trials the dots would
remain still (A) while in other trials they would move together left or right with a constant speed (B). Subject indicated the
direction of motion of the dots. From this result, the authors estimated the speed of subjective stationarity, i.e., the speed of
dots for which the subject perceived them to be stationary. C) The unfilled circles represent performance of control subjects.
Regardless of the speed of the cursor, they perceived the dots to be stationary only if their speed was near zero. The filled
triangles represent performance of subject RW. As the speed of the cursor increased, RW perceived the dots to be stationary if
their speed was near the speed of the cursor. (Haarmeier et al., 1997)
Disorders of agency in schizophrenia relate to an inability to compensate for sensory consequences of self-generated
motor commands. In a paradigm similar to that shown in the last figure, volunteers estimated whether during motion of a
cursor the background moved to the right or left. By varying the background speed, at each cursor speed the
experimenters estimated the speed of perceptual stationarity, i.e., the speed of background motion for which the subject
saw the background to be stationary. They then computed a compensation index as the difference between speed of
eye movement and speed of background when perceived to be stationary, divided by speed of eye movement. The
subset of schizophrenic patients who had delusional symptoms showed a greater deficit than control in their ability to
compensate for sensory consequences of self-generated motor commands. (From (Lindner et al., 2005))
Combining predictions with observations
A
C
B
D
Parameter variance depends only on input selection and noise
A noisy process produces
n data points and we form
an ML estimate of w.
y*(i )  w*T x(i )
y (i )  y*(i )  



N 0, 2


 
D (1)  x(1) , y (1,1) , x(2) , y (1,2) ,

T
w ML  X X
We run the noisy process
again with the same
sequence of x’s and reestimate w:


1
 ,x(n) , y(2,n) 


w ML  X X
The distribution of the
resulting w will have a var- w ML
cov that depends only on
the sequence of inputs, the
bases that encode those
inputs, and the noise
sigma.

1

X T y (1)
D (2)  x(1) , y (2,1) , x(2) , y (2,2) ,
T
, x( n) , y (1,n)
X T y (2)


 * 2 T 1 
N  w , X X



The Gaussian distribution and its var-cov matrix
A 1-D Gaussian distribution is defined as
In n dimensions, it generalizes to
When x is a vector, the variance is
cij
expressed in terms of a covariance
matrix C, where ρij corresponds to the
degree of correlation between variables
xi and xj

 ( x   )2 
p ( x) 
exp  
2
2 2 
2

1
p ( x) 
 1

exp   (x  x)T C 1 (x  x) 
 2

(2 ) n | C |
1
 E ( xi  xi )( x j  x j )   E  xi x j   xi x j
  12

 
C   12 1 2


 1n 1 n
12 1 2
 22
1n 1 n 

 2 n 2 n 
 2 n 2 n
 n2
 ( xi   x )( yi   y )
i
 ( xi   x )2  ( yi   y )2
i
i

Cxy
Cxx C yy




Cxy
 x y
N  μ, C 
x
  12
C
 12 1 2
x1 and x2 are positively correlated
x
12 1 2 

 22 
x1 and x2 are not correlated
 0   1
0.9 2  

N  ,

 0 0.9 2
2  


x
3
 0   1
0.1
N  ,
 0 0.1 2
2


x1 and x2 are negatively correlated
2

 
x
4
3
3
2
 0   1
0.9 2  

N  ,

 0  0.9 2
2  


2
2
1
x2
1
1
0
0
0
-1
-1
-1
-2
-2
-2
-3
-2
-1
0
x1
1
2
3
-3
-2
-1
0
1
2
3
4
-2
-1
0
1
2
3
Parameter uncertainty: Example 1
• Input history:
yˆ  w1x1  w2 x2  xT w
*
x1
x2
y
1
0
0.5
1
0
0.5
1
0
0.5
1
0
0.5
0
1
0.5
1
1

X  1

1
 0
0
0 
0

0
1 
w ML

 var  w1 
cov  w1 , w2  
N  E[w ], 
 

cov
w
,
w
var
w




2 1
2 




 * 2 T 1 
N  w , X X



 0.5 2 0.25 0 
N    , 
 
0.5
0
1


 
2
x1 was “on” most of the time. I’m pretty
certain about w1. However, x2 was “on”
only once, so I’m uncertain about w2.
1.5
1
w2
0.5
0
-0.5
-0.5
0
0.5
w1
1
1.5
2
Parameter uncertainty: Example 2
• Input history:
*
x1
x2
y
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0.5
w ML
1
1

X  1

1
1
1
1 
1

1
0 

 var  w1 
cov  w1 , w2  
N  E[w ], 
 

var  w2   
cov  w2 , w1 

 * 2 T 1 
N  w , X X



 0.5
1  
1
N    , 2 
 
0.5

1
1.25


 


2
x1 and x2 were “on” mostly together. The
weight var-cov matrix shows that what I
learned is that: w1  w2  1
I do not know individual values of w1 and w2
with much certainty.
x1 appeared slightly more often than x2, so
I’m a little more certain about the value of
w1.
1.5
1
w2
0.5
0
-0.5
-0.5
0
0.5
w1
1
1.5
2
Parameter uncertainty: Example 3
• Input history:
*
x1
x2
y
0
1
0.5
0
1
0.5
0
1
0.5
0
1
0.5
1
1
1
w ML

 var  w1 
cov  w1 , w2  
N  E[w ], 
 

var  w2   
cov  w2 , w1 

 * 2 T 1 
N  w , X X



 0.5
 1.25 0.25 
N    , 2 
 
0.5

0.25
0.25


 
x2 was mostly “on”. I’m pretty certain about
w2, but I am very uncertain about w1.
Occasionally x1 and x2 were on together, so
I have some reason to believe that: w  w  1
1
2


2
1.5
1
w2
0.5
0
-0.5
-0.5
0
0.5
w1
1
1.5
2
Effect of uncertainty on learning rate
• When you observe an error in trial n, the amount that you should change w
should depend on how certain you are about w. The more certain you are, the
less you should be influenced by the error. The less certain you are, the more
you should “pay attention” to the error.
mx1
mx1
error

w( n1)  w( n)  k ( n) y( n)  x( n)T w( n)

Kalman gain
Rudolph E. Kalman (1960) A new approach to linear filtering and
prediction problems. Transactions of the ASME–Journal of Basic
Engineering, 82 (Series D): 35-45.
Research Institute for Advanced Study
7212 Bellona Ave, Baltimore, MD
Example of the Kalman gain: running estimate of average
x (i )  1
y (i )  y*(i )  
y*(i )  w* ;
X T  1 1
n

w( n)  X T X
( n 1)
w



N 0,  2

1
1
1 n (i )
T
X y
y
n i 1

w(n) is the online estimate of the mean of y
1 n 1 (i )

y
n  1 i 1

Past estimate
New measure
n 1

 1
1
1
 1
( n)
(i )
( n)
w  
y  y    n  1 w( n 1)  y ( n)  1   w( n 1)  y ( n)
 n
n  i 1
n
 n



w( n)  w( n 1) 

1 ( n)
y  w( n 1)
n


As n increases, we trust our past estimate
w(n-1) a lot more than the new
observation y(n)
Kalman gain: learning rate decreases as the number of
samples increase
Example of the Kalman gain: running estimate of variance
sigma_hat is the online estimate of the var of y
ˆ (2n)




n
2
1
(i )

y  E  y
n i 1
n
2
1
(i )
( n)

y w
n i 1
2
2
1  n 1 (i )
( n)
( n)
( n)
 
y w
 y w

n  i 1


 



2
1
2
(
n
)
(
n
)
  n  1 ˆ ( n 1)  y  w

n

2
1 2
1 ( n)
2
( n)
ˆ
ˆ
  ( n 1)   ( n 1)  y  w
n
n
2

1  ( n)
2
2
(
n
)
ˆ ( n)  ˆ ( n 1)   y  w
 ˆ (2n 1) 
n





Some observations about variance of model parameters
y ( n)  x( n)T w*   ( n)
w
n 1



N 0, 2
n
n
 w    k ( n) y ( n)  x( n)T w  


n
n
P   var  w   


T
  n 
n     n 
n   




 E  w  E w
 w  E  w   



 

 


T
 n
n

*
* 
 E w w w w



n
nT
 E w w  


n
nT
n
trace  P    E  w   w   







We note that P is simply the var-cov matrix of our model weights. It represents the uncertainty in our
estimates of the model parameters.
We want to update the weights in such a way as to minimize the trace of this variance. The trace is
the sum of the squared errors between our estimates of w and the true estimates.
Trace of parameter var-cov matrix is the sum of squared parameter errors
P  E  wwT 


w 
w   1
 w2 
 0   var  w1 
cov  w1 , w2   
N  0, P   N    , 
 
 0  cov  w2 , w1 
var  w2   




n
2 1 n (i )2
1
(i )
var  w1  
w  E  w1  
w
n i 1 1
n i 1 1

n

1
trace  P   var  w1   var  w2  
w1(i )2  w2(i )2
n i 1
Our objective is to find learning rate k (Kalman gain) such that we minimize the
sum of the squared error in our parameter estimates. This sum is the trace of the
P matrix. Therefore, given observation y(n), we want to find k such that we
minimize the variance of our estimate w.
w
n n
 w
n n1
n n 1 

 k ( n)  y ( n)  x( n)T w 



Objective: adjust learning gain in order to minimize model uncertainty
Hypothesis about data observation in trial n
my estimate of w* before I see y in trial n,
given that I have seen y up to n-1
error in trial n
my estimate after I see y in trial n
P
n n 1
y ( n)  x( n)T w*   ( n)
w

N 0, 2

n n1
y ( n)  x( n)T w 
w

n n
 w
n n1
n n 1
n n 1 

 k ( n)  y ( n)  x( n)T w 



 n n 1 
a prior variance of parameters
 var  w 



T
 n n 1


n
n

1
n
n

1
n
n

1




  E w
 w
  E w
 
 E  w 




  


 

 n n   var  w  n n   a posterior variance of parameters
P


T
 n n
n n     n n 
n n  






 E  w
 E w
 E w
 w
 




 

 


Evolution of parameter uncertainty
w
n n 1 

 k ( n)  y ( n)  x( n)T w 



 n n   w n n1  k (n)  x(n)T w*   (n)  x(n)T w  n n1 
w




w*  w
n n
 w
n n 1
 n n   w*  w  n n1  k (n) x(n)T w*  k (n) (n)  k (n) x(n)T w  n n1


n n 1 

(n) ( n)
 I  k ( n) x( n)T  w*  w 
k 



n n

 n n   w*  w  n n  
P
 E  w*  w

 
 
T




T



n
n

1
n
n

1








( n) ( n)
( n ) ( n )T
*
( n) ( n)
 E  I  k ( n) x( n)T  w*  w
  k   I  k x
w  w
k   






 





T


T
n n 1  *
n n 1 


( n ) ( n )T  *
( n ) ( n)T
( n) ( n) ( n)T ( n )T
 E I k x
k  
k

w  w
 w  w
 I k x











  E k (n) (n) (n)T k (n)T 
T
n n
n n 1


( n ) ( n )T
( n ) ( n )T
P
 I  k x
 P  I  k x   k (n) 2k (n)T
 I  k ( n ) x( n)T P
n n 1
I  k ( n ) x( n)T
T

Find K to minimize trace of uncertainty
P
w
 n n   w n n1  k (n)  y (n)  x(n)T w  n n1 
w
 n n   w n n1  k (n)  x(n)T w*   ( n)  x( n)T w  n n1 
w
n n 






I  k ( n) x( n)T w




 n n1  k (n) (n)  k (n) x( n)T w*
 n n1  var  w n n1 


nn
 nn 
P   var  w   


x


 I  k x   k (n) var  (n)  k (n)T
T
n n
n n 1


( n) ( n)T
( n) ( n)T
P
 I  k x
 P  I  k x   k (n) 2k (n)T
 I k
( n) ( n)T
 n n1
P
( n) ( n)T
T
Find K to minimize trace of uncertainty
nn
P  
I  k
 P
( n) ( n)T
n n 1
x
 P

n n 1
P
I  k
n n 1 ( n) ( n)T
x
k
( n) ( n)T
x

T
 k ( n) 2k ( n)T
 k ( n) x( n)T P
n n 1
 k ( n) x( n)T P
n n 1 ( n) ( n )T
 n n 
  n n1 
  n n1 ( n) ( n)T 
 ( n) ( n)T  n n1 
tr  P

tr
P

tr
P
x
k

tr
k x
P
















 n n1 x(n)   2  k (n)T 
tr k ( n)  x( n)T P






x
k
 k (n) 2k (n)T
tr  A  tr  AT 
 
P  PT
 ( n)  ( n)T  n n1 ( n)
 n n1 
  n n1 ( n) ( n)T 
2  ( n )T 
 tr  P

2
tr
P
x
k

tr
k
x
P
x



k













scalar




n n 1 ( n )
n n 1 ( n )



tr k ( n)  x( n)T P
x   2  k ( n)T   tr  x( n)T P 
x   2  k ( n)k ( n)T 








 n n1 x( n)   2  tr k ( n)k ( n)T 
  x( n)T P
 



n n 1 ( n )


  x( n)T P
x   2  k ( n)T k ( n)


tr  aB  atr  B
The Kalman gain
 nn 
 n n 1 
  n n 1 ( n) ( n)T   ( n )T  n n 1 ( n )
2  ( n )T ( n )
tr  P    tr  P 

2
tr
P
x
k

x
P
x


k

k








 

 n n 1 
( n )T  n n 1 ( n )  ( n )T  n n 1 ( n )
2  ( n )T ( n )
 tr  P

2
k
P
x

x
P
x


k

k







 n n 
 n n1 x( n)   x( n)T P n n1 x( n)   2  2k ( n)  0
tr  P


2
P





dk ( n ) 
d
k
( n)

P
n n 1 ( n )
x
 ( n)T  n n 1 ( n )
2
x
P
x






If I have a lot of uncertainty about my model, P is large
compared to sigma. I will learn a lot from the current error.
If I am pretty certain about my model, P is small compared
to sigma. I will tend to ignore the current error.
Update of model uncertainty
P
 n n   P n n1  P n n 1 x( n)k ( n)T
k
( n)
 k ( n) x( n)T P
n n 1 ( n )  ( n )T  n n 1 ( n )

 P
x
x
P
x  2


 n n 1  k ( n)  x( n)T P n n 1 x( n)   2  k ( n)T




1


nn
n n 1
n n 1 ( n )  ( n )T  n n 1 ( n )

P   P
 P
x
x
P
x  2


T


x( n)T P
n n 1
n n 1 ( n )  ( n )T  n n 1 ( n )

 P
x
x
P
x  2
1
x( n)T P
 n n1 x( n)  x( n)T P n n1 x( n)   2 
P
1
 ( n)T  n n 1 ( n)

P
x  2 
x











 n n1 x(n)   2 
  x( n)T P



T
x( n)T P
 n n1
n n 1
n n 1 ( n )  ( n )T  n n 1 ( n )

 P
 P
x
x
P
x  2


n n 
P
I  k
( n ) ( n )T
x

 n n1
P
n n 1


1
x( n)T P
Model uncertainty decreases with
every data point that you observe.
n n 1
Hidden variable
w*
x
w*
x
w*
In this model, we hypothesize that the
hidden variables, i.e., the “true”
weights, do not change from trial to
trial.
x
Observed
variables
y
y
y
w*( n 1)  w*( n)
y ( n)  x( n)T w*   ( n)
A priori estimate of mean and variance of the
hidden variable before I observe the first data point
Update of the estimate of the hidden
variable after I observed the data point
w
1 0
w
k
P
Forward projection of the
estimate to the next trial
P


1 0
 w
n n 1
P
n 1 n 

n n 1 

 k ( n)  y ( n)  x( n)T w 



 n n1 x( n)
x( n)T P
n n 
w

N 0, 2
, P
n n
(n)

n n 1 ( n )
x

 2
I  k ( n) x( n)T P
 w
n n
 n1 n   P n n 
 n n1
w*
x
w*
x
y
w*
In this model, we hypothesize that
the hidden variables change from
trial to trial.
x
y
A priori estimate of mean and variance of the
hidden variable before I observe the first data point
y
w*( n 1)  Aw*( n)  ε (wn)
εw
N  0, Q 
y ( n)  x( n)T w*   (yn)
y
N 0, 2
w
P
x( n)T P
w
P
Forward projection of the
estimate to the next trial
P
n n
 w
n n 
w

1 0  , P1 0 
k (n) 
Update of the estimate of the hidden
variable after I observed the data point


 n n1 x( n)
 n n1 x( n)   2
n n 1
n n 1 

 k ( n)  y ( n)  x( n)T w 




I  k ( n) x( n )T P
 n1 n   Aw  n n 
 n1 n   AP n n  AT
Q
 n n1
Uncertainty about my model parameters
P
k (n) 
x( n)T P
n n 1 ( n )
x
 n n1 x(n)   2
Uncertainty about my measurement
• Learning rate is proportional to the ratio between two uncertainties: my model vs. my
measurement.
• After we observe an input x, the uncertainty associated with the weight of that input
decreases.
 n n
 n n1
(n) (n)T

 I k
P
x
P
• Because of state update noise Q, uncertainty increases as we form the prior for the
next trial.
P
 n1 n   AP n n  AT
Q
2. Bayesian state estimation
3. Causal Inference
4. The influence of priors
5. Behaviors that are not Bayesian
Comparison of Kalman gain to LMS
w*( n 1)  w*( n)
y ( n)  x( n)T w*   ( n)
See derivation of
this in homework
k ( n) 
P


N 0,  2

 n n  x( n )
2
n
n 1
n 1
w    w    k ( n) y ( n)  x( n)T w  

n n
P
n 1
 w  
2

y ( n)  x( n)T w 

n 1

x( n )
In the Kalman gain approach, the P matrix depends on the history of all previous and current
inputs. In LMS, the learning rate is simply a constant that does not depend on past history.


n
n1
n1
w   w    y(n)  x(n)T w  x(n)
With the Kalman gain, our estimate converges on a single pass over the data set. In LMS,
we don’t estimate the var-cov matrix P on each trial, but we will need multiple passes before
our estimate converges.
Effect of state and measurement noise on the Kalman gain
( n)
w(*n1)  aw(*n)   w
y ( n)  x( n)T w*   (yn)
n1 n
P
w
a  0.99
x =1
y

N 0, q 2

N 0,  2
5
5
4.5
4.5
n1 n
P
4
3.5
3.5
3
2.5
2.5
2
2
4
6
8
10
2
4
q2  2, 2  1
0.75
0.7
0.65
0.7
2
4
6
8
10
High noise in the state update model
produces increased uncertainty in model
parameters. This produces high learning
rates.
10
q2  1, 2  2
0.55
0.5
2
8
q2  1, 2  1
0.65
0.6
q  1,  1
2
0.75
k (n)
6
q2  2, 2  1
0.8
0.8
k
4
3
2
(n)


2
4
6
8
10
High noise in the measurement also
increases parameter uncertainty. But this
increase is small relative to measurement
uncertainty. Higher measurement noise
leads to lower learning rates.
Effect of state transition auto-correlation on the Kalman gain
( n)
w(*n1)  aw(*n)   w
w
y ( n)  x( n)T w*   (yn)

N 0, q 2
y
x =1

q2  1

N 0, 2

 2 1
5
 n1 n
P
4
3
2
1
2
4
6
8
10
0.8
k (n)
0.75
0.7
a  0.99
0.65
0.6
0.55
0.5
2
4
6
8
10
a  0.50
a  0.10
Learning rate is higher in a state model that has high autocorrelations (larger a). That is, if the learner assumes that the
world is changing slowly (a is close to 1), then the learner will
have a large learning rate.
Kalman filter as a model of animal learning
Suppose that x represents inputs from the environment: a light and a tone.
Suppose that y represents rewards, like a food pellet.
Animal’s model of the experimental setup
w
*
x
w
*
w
x
y
Animal’s expectation on trial n

yˆ ( n)  x( n)T w
*
x
y ( n)  x1w1*  x2 w2*   (yn)
y
εw
N  0, Q 
y
n n 1
Animal’s learning from trial n
y
w*( n1)  Aw*( n)  ε (wn)
light 
x

 tone 

N 0, 2
P
k ( n) 

w
P
n n
x( n)T P
 w
n n 
w
P

n n 1 ( n)
x
 n n1 x(n)   2
n n 1
n n 1 

 k ( n)  y ( n)  x( n)T w 




I  k ( n) x( n)T P
n 1 n 
 Aw 
n 1 n 
 AP
n n
n n T
A Q
 n n1
Various forms of classical conditioning in animal psychology
Not explained
by LMS, but
predicted by
the Kalman
filter.
Table from Peter Dayan
Sharing Paradigm
1
Train: {x1,x2} -> 1
y*
x2
x1
0
0
Test: x1 -> ?, x2 -> ?
10
20
30
40
Result: x1->0.5, x2->0.5
Learning with Kalman gain
yhat
y
LMS
0.5
0.45
1.5
1.5
0.4
1
1
0.35
0.3
0.5
0.5
0.25
P22
P11
0.2
0
10
20
30
10
40
0.8
0.6
0.4
20
30
40
0
0
w2
w1
10
20
30
40
0
0.4
0.7
0.35
0.6
0.3
0.5
0.25
0.4
10
20
30
40
0.3
0.2
0.2
yhat
y
0.2
0.15
k2
k1
0.1
10
20
30
40
0.1
0
0
w2
w1
10
20
30
40
Blocking
Kamin (1968) Attention-like processes in classical conditioning. In: Miami
symposium on the prediction of behavior: aversive stimulation (ed. MR Jones), pp. 933. Univ. of Miami Press.
Kamin trained an animal to continuously press a lever to receive food. He then
paired a light (conditioned stimulus) and a mild electric shock to the foot of the rat
(unconditioned stimulus). In response to the shock, the animal would reduce the
lever-press activity. Soon the animal learned that the light predicted the shock, and
therefore reduced lever pressing in response to the light. He then paired the light
with a tone when giving the electric shock. After this second stage of training, he
observed than when the tone was given alone, the animal did not reduce its lever
pressing. The animal had not learned anything about the tone.
Blocking Paradigm
1
Train: x1 -> 1, {x1,x2} -> 1
0
y*
x2
x1
0
Test: x2 -> ?, x1 -> ?
10
20
30
40
Result: x2 -> 0, x1 -> 1
Learning with Kalman gain
LMS
0.5
1.5
0.4
1.5
0.3
1
1
0.2
0.5
0.5
yhat
y
0
10
20
30
0.1
40
10
1.25
0.6
1
0.5
0.75
0.4
0.5
0.3
0.25
0.2
0
-0.25
0
w2
w1
10
20
30
40
P22
P11
20
30
yhat
y
0
40
10
20
30
40
1.2
1
0.8
0.6
0.4
0.2
0.1
k2
k1
0
10
20
30
40
w2
w1
0
-0.2
0
10
20
30
40
Backwards Blocking Paradigm
1
Train: {x1,x2} -> 1, x1 -> 1
y*
x2
x1
0
Test: x2 -> ?
0
10
20
30
40
50
60
Result: x2 -> 0
Learning with Kalman gain
LMS
0.5
1.5
1
0.4
1.5
0.3
1
0.2
0.5
0.5
yhat
y
0
0
10
20
30
40
50
60
0.1
0
P22
P11
10
20
30
40
50
60
0.4
1
0.8
0.2
10
20
30
40
50
60
0.8
0.6
0
0.4
0.2
-0.2
0
-0.2
0
0
1
0.6
0.4
yhat
y
0
w2
w1
10
20
30
40
50
60
-0.4
0
k2
k1
10
20
30
40
50
60
0.2
w2
w1
0
0
10
20
30
40
50
60
Different output models
Suppose that x represents inputs from the environment: a light and a tone.
Suppose that y represents a reward, like a food pellet.
Case 1: the animal assumes an additive model.
If each stimulus predicts one reward, then if
the two are present together, they predict two
rewards.
Case 2: the animal assumes a weighted
average model. If each stimulus predicts
one reward, then if the two are present
together, they still predict one reward, but
with higher confidence.
The weights b1 and b2 should be set to the
inverse of the variance (uncertainty) with
which each stimulus x1 and x2 predicts the
reward.
w*( n 1)  Aw*( n )  ε (wn )
light 
x

 tone 
y ( n )  xT w*( n )   (yn )  y
w*( n 1)  Aw*( n )  ε (wn)


N  0, Q 
εw

N 0, 2
εw
y  b1 x1w1*  b2 x2 w2*  b1  b2 

N  0, Q 
1
y
General case of the Kalman filter
nx1
mx1
A priori estimate of mean and
variance of the hidden variable
before I observe the first data point
w*( n)  Aw*( n 1)  ε(wn)
εw
N  0, Q 
y ( n)  H x( n) w*( n)  ε(yn)
εy
N  0, R 
 
w
1 0
, P
1 0
1
T


n
n

1
 H x( n)  R
k ( n)  P
H x( n)  H x( n) P 



nn
n n 1
n n 1 

w   w
 k ( n)  y ( n)  H x( n) w 



 
 n n1
Update of the estimate of the
hidden variable after I observed
the data point
 
P
Forward projection of the
estimate to the next trial
 
T
n n 
w
P

 
I  k ( n ) H x( n)
n 1 n 
 Aw 
n 1 n 
 AP
n n
n n T
A Q
P
 n n1
 
How to set the initial var-cov matrix
w*( n )  Aw*( n 1)  ε (wn)
εw
N  0, Q 
y ( n )  H ( n ) w*( n )  ε (yn )
εy
N  0, R 
P
1 0   ?
In homework, we will show that in general:
  n n 
P



1
  n n1 
P



1
 H T R 1H
Now if we have absolutely no prior information on w, then before we see the first data point P(1|0) is
infinity, and therefore its inverse in zero. After we see the first data point, we will be using the above
equation to update our estimate. The updated estimate will become:
 11 
P



1
 H T R 1 H
11 
P
H
T

1
R H
1
A reasonable and conservative estimate of the initial value of P would be to set it to the above value.
That is, set:
10
P  
H
T 1
R H

1
Data fusion
Suppose that we have two sensors that independently measure something. We would like
to combine their measures to form a better estimate. What should the weights be?
Suppose that we know that sensor 1 gives us measurement
y1 and has Gaussian noise with variance:  2
1
And similarly, sensor 2 has gives us measurement y2 and
has Gaussian noise with variance:  2
2
A good idea is to weight each sensor inversely proportional
to its noise:
 1
xˆ  
2
 1
 1

2
 1

y1 
y1 
 22
12
1
 22
1
 22
 1
1 
y2 


  2  2 
2 
 1
  2 2 
y2  1 2 
  2   2 
2 
 1
12
y 
2 1
2
12
  22
y2
1
Data fusion via Kalman filter
xˆ 
 22
12
12
y 
2 1
2
12
  22
y2
To see why this makes sense, let’s put forth a generative model that describes
our hypothesis about how the data that we are observing is generated:
x*
Hidden variable
Observed variables
y1
x(*n1)  ax(*n)   x( n*)
1
y ( n)    x(*n)  ε(yn)
1
x*
y2
y1
 x*
εy

N 0, q 2
y2

N  0, R 
 2 0 

R 1
2
 0  2 
y
( n)
xˆ 
1 0
1
   x(*n)  ε(yn)
1
our first observation
 1 0  
P



12 22
11

P

See
homework for
this
1
H  
1
priors
 y (1) 
y (1)   1 
 y (1) 
 2 
1
N  0, R 
0
1 0  
P
 11 
P



εy
 2 0 

R 1
2
 0  2 
12
1
  22
 H T R 1H 
1
12

1
 22
variance of our posterior estimate
 1
 2
2 2



11
k (1)  P  H T R 1  1 2 1 1  1

12   22
 0

11
10
10 

xˆ    xˆ    k (1) y (1)  Hxˆ   




 22

0 
2 2

  12
1  12   22
2
 2 
y1(1)
12   22

2
 1   2 

 2  2
2
 1    1   2 

 1  
2
 2   1 
  2   12   22 
12
12   22
y2(1)
x*
The real world
What our sensors tell us
y1
y2
12 22
11

P

Notice that after we make our first
observation, the variance of our
posterior is better than the
variance of either sensor.
12   22
12
 22


12 22


12 22


because 12 12   22  12 22
12   22
because  22 12   22   2212
12   22
Combining equally noisy sensors
y1

N y1(1) ,12
Sensor 1


N y2(1) , 22
y2
Combined
Combining sensors with unequal noise

Sensor 1
Sensor 2
Combined
Sensor 2
probability
0.5
0.4
0.4
0.3
0.3
0.2
0.2
0.1
0.1
0
0
-2
xˆ
0
2
4
6
8
10
2 2
 2
12
(1)
(2) 1  2
2
N
y 
y ,
2
2 1
 2  2 1
1   2
12   22
2
 1
-2.5




Mean of the posterior, and its variance
0
2.5
5
7.5
10
12.5
15
Puzzling results: Savings and memory despite “washout”
Gain=eye displacement
divided by target
displacement
1
Result 1: After
changes in gain,
monkeys exhibit
recall despite
behavioral
evidence for
washout.
Kojima et al. (2004) Memory of learning facilitates saccade adaptation in the monkey. J Neurosci 24:7531.
Puzzling results: Improvements in
performance without error feedback
Result 2: Following changes in
gain and a long period of washout,
monkeys exhibit no recall.
Result 3: Following changes in
gain and a period of darkness,
monkeys exhibit a “jump” in
memory.
Kojima et al. (2004) J Neurosci 24:7531.
The learner’s hypothesis about the structure of the world
1. The world has many hidden states. What I observe is a linear combination of
these states.
2. The hidden states change from trial to trial. Some change slowly, others
change fast.
3. The states that change fast have larger noise than states that change slow.
w*
x
A
w*
x
y
y
state transition equation
output equation
 w*  slow system
w  1
 w2*  fast system
0 
 0.99
A
0.50 
 0
*
w*( n)  Aw*( n 1)  ε (wn)
y ( n)  x( n)T w*( n)  ε(yn)
εw
N  0, Q 
εy
N 0,  2


1
Simulations for savings
 w* 
w*   1 
 w2* 
0 
0.99
A

0
0.50


w
*( n )
 Aw
*( n 1)
 ε (wn)
-1
0
50
100
150
200
250
300
1.5
1
0.5
0
εw
0 
0.00004
Q

0
0.01


y ( n)  x( n)T w*( n)  ε(yn)
y*
x2
x1
0
-0.5
N  0, Q 
-1
yhat
y
-1.5
0.6 0
εy

N 0,  2

  0.04
50
100
150
200
250
300
0.4
0.2
0
2
-0.2
w2
w1
-0.4
The critical assumption is that in the fast
system, there is much more noise than in the
slow system. This produces larger learning rate
in the fast system.
0
1.25
50
100
150
200
250
300
1
0.75
0.5
0.25
0
-0.25
k2
k1
-0.5
0
50
100
150
200
250
300
Simulations for spontaneous
recovery despite zero error
feedback
1
0.5
error clamp
In the error clamp period, estimates are made yet
the weight update equation does not see any error.
Therefore, the effect of Kalman gain in the errorclamp period is zero. Nevertheless, weights
continue to change because of the state update
equations. The fast weights rapidly rebound to
zero, while the slow weights slowly decline. The
sum of these two changes produces a
“spontaneous recovery” after washout.
0
-0.5
y*
x2
x1
-1
0
50
100
150
200
250
300
1.5
1
0.5
0
-0.5
-1
 n n   w n n1  k (n)  y(n)  x(n)T w n n1 
w
 n1 n   Aw n n 
w


-1.5


yhat
y
0
50
100
150
200
250
300
0.4
0.2
0
-0.2
-0.4
w2
w1
0
50
100
150
200
250
300
Changes in representation without error feedback
Target visible during recovery
Mean gain at start Mean gain at end
of recovery = 0.83 of recovery = 0.95
% gain change = 14.4%
Seeberger et al. (2002) Brain Research 956:374-379.
Target extinguished during recovery
Mean gain at start Mean gain at end
of recovery = 0.86 of recovery = 0.87
% gain change = 1.2%
Massed vs. Spaced training: effect of changing the inter-trial interval
ITI = 8min
ITI = 1min
Han, J.S., Gallagher, M. & Holland, P.
Hippocampus 8:138-46 (1998)
Discrimination performance (sec)
Learning reaching in a force field
Rats were trained on an operant conditional
discrimination in which an ambiguous stimulus (X)
indicated both the occasions on which responding in the
presence of a second cue (A) would be reinforced and the
occasions on which responding in the presence of a third
cue (B) would not be reinforced (X --> A+, A-, X --> B-, B+).
Both rats with lesions of the hippocampus and control
rats learned this discrimination more rapidly when the
training trials were widely spaced (intertrial interval of 8
min) than when they were massed (intertrial interval of 1
min). With spaced practice, lesioned and control rats
learned this discrimination equally well. But when the
training trials were massed, lesioned rats learned more
rapidly than controls.
Massed vs. Spaced training: effect of changing the inter-trial interval
Performance in a water maze
4 trials a day for 4 days
16 trials in one day
Sisti, Glass, Shors (2007) Neurogenesis and the spacing effect: learning over time enhances memory and the survival of new neurons.
Learning and Memory 14:368.
The learner’s hypothesis about the structure of the world
1. The world has many hidden states. What I observe is a linear combination of
these states.
2. The hidden states change from trial to trial. Some change slowly, others
change fast.
3. The states that change fast have larger noise than states that change slow.
4. The state changes can occur more frequently than I can make observations.
w*
A
w*
A
w*
A
x
A
w*
A
w*
x
y
y
Inter-trial interval
 w* 
w*   1 
 w2* 
0 
0.999
A
0.40 
 0
w*( n)  Aw*( n 1)  ε (wn)
0.00008 0 
Q

0
0.1


y ( n)  x( n)T w*( n)  ε(yn)
εw
N  0, Q 
εy
N 0,  2


 2  0.04
ITI=2
ITI=20
1.5
1.5
1
1
0.5
0.5
y
yhat
0
0
50
100
150
200
250
y
yhat
0
300
0
500
1000
1500
2000
2500
3000
P
When there is an observation, the uncertainty for
each hidden variable decreases proportional to its
Kalman gain.
P
When there are no observations, the uncertainty
decreases in proportion to A squared, but increases
in proportion to state noise Q.
n n
n 1 n 


 I  k ( n) x( n)T P
 AP
n n 1
n n T
A Q
 a2 P
  11 11
 a11a22 P12
a11a22 P12 
Q
2
a22 P11 
ITI=20
Uncertainty for the slow state
Uncertainty for the fast state
0.0136
0.118
0.0134
0.116
0.114
0.0132
0.112
0.013
0.11
0.0128
P11
0.0126
1000
1020
1040
1060
1080
1100
0.108
0.106
1000
P22
1020
1040
1060
1080
1100
Beyond a minimum ITI, increased ITI continues to increase the uncertainty of the
slow state but has little effect on the fast state uncertainty. The longer ITI increases
the total learning by increasing the slow state’s sensitivity to error.
Performance in spaced training depends largely on the slow state. Therefore,
spaced training produces memories that decay little with passage of time.
1.5
0.8
1
w1spaced
0.6
w1massed
0.4
0.5
w2massed
y
0.2
yhatspaced
0
0
yhatmassed
w2spaced
0
20
40
60
80
100
120
-0.2
140
0
0.3
20
40
60
80
0.8
100 120 140
k2massed
0.25
0.2
k2spaced
0.6
0.15
P22spaced
0.1
0.4
P22massed
0.05
P11spaced
0
P11massed
0.2
P12spaced
-0.05
k1spaced
P12massed
k1massed
0
20
40
60
80
100
120
140
0
Observation number
20
40
60
80
100 120 140
Spaced training results in better retention in learning a second language
On Day 1, subjects learned to translate written Japanese words into English. They were given a Japanese word
(written phonetically), and then given the English translation. This “study trial” was repeated twice. Afterwards,
the were given the Japanese word and had to write the translation. If their translation was incorrect, the correct
translation was given.
The ITI between word repetition was either 2, 14, or 98 trials.
Performance during training
Testing at 1 day or 1 week (averaged together)
ITI=2
ITI=14
ITI=98
ITI=14
ITI=98
Test at 1 week
ITI=2
Pavlik, P. I. and Anderson, J. R. ( 2005). Practice and forgetting effects on
vocabulary memory: An activation-based model of the spacing effect.
Cognitive Science, 29, 559-586.
Performance during training was better when the ITI was short. However, retention was much better for words
that were observed with longer ITI. (The retention test involved two groups; one at 1 day and other at 7 days.
Performance was slightly better for the 1 day group but the results were averaged in this figure.)
Application of Kalman filter to problems in sensorimotor control
Motor command
u
u
State of our body
x
x
x
y
y
y
Sensory measurement
DM Wolpert et al. (1995) Science 269:1880
When we move our arm in darkness, we may estimate the position of our hand based
on three sources of information:
• proprioceptive feedback.
• a forward model of how the motor commands have moved our arm.
• by combining our prediction from the forward model with actual proprioceptive
feedback.
Experimental procedures:
Subject holds a robotic arm in total darkness. The hand is briefly illuminated. An
arrow is displayed to left or right, showing which way to move the hand. In some
cases, the robot produces a constant force that assists or resists the movement. The
subject slowly moves the hand until a tone is sounded. They use the other hand to
move a mouse cursor to show where they think their hand is located.
DM Wolpert et al. (1995) Science 269:1880
assistive
resistive
DM Wolpert et al. (1995) Science 269:1880
The generative model, describing actual dynamics of the limb
Motor
command
State of
the body
u
u
B
A
x
x
x
x( n1)  Ax( n)  Bu ( n)  ε(xn)
εx
N  0, Q 
y ( n)  Cx(n)  ε(yn)
εy
N  0, R 
C
Sensory
measurement
y
y
y
The model for estimation of sensory state from sensory feedback
ˆ ( n)  ε( n)
x( n1)  Aˆ x( n)  Bu
x
y ( n)  Cˆ x( n)  ε(yn)
εx
N  0, Q 
εy
N  0, R 
Bˆ  1.4 B
For whatever reason, the brain has an incorrect
model of the arm. It overestimates the effect of
motor commands on changes in limb position.
Initial conditions: the subject can see the
hand and has no uncertainty regarding its
position and velocity

xˆ
0 0
1 0
P
0
xˆ 
00
ˆ 1
 Aˆ xˆ    Bu
1 0
Forward model of state change
and feedback
Actual observation
1
1 0 
yˆ    Cˆ xˆ
y (1)  Cx(1)
(1)
1 0 Cˆ T  CP
ˆ 1 0 Cˆ T
P
xˆ 
11
 xˆ 
P
11
10
 I  k (1)Cˆ T P  

xˆ
21
11  Bu
ˆ  2
 Aˆ xˆ
P
21
ˆ 11 Aˆ T  Q
 AP
k
Estimate of state incorporates
the prior and the observation
Forward model to establish the
prior and the uncertainty for the
next state
0
 x 
1 0





 R

1
 k (1) y (1)  yˆ  


1
A single movement
Pos (cm)
20
xˆ  SD xˆ 
15
x t 
10
Actual and
estimated
position
5
For movements of various length
0
0
0.2 0.4 0.6 0.8
1
1.2 1.4
1.8
1.5
1
P
1.6
Motor command u
0.5
Variance at end of movement (cm^2)
1.4
0
1.2
-0.5
Time of “beep”
-1.5
0
0.2
0.4
0.6
0.8
xˆ  x
1
-1
1
1.2
1.4
0.8
Bias at end of movement (cm)
0.014
0
0.012
0.5
1
1.5
2
Total movement time (sec)
0.01
0.008
0.006
0.004
Kalman gain
0.002
0
0
0.2 0.4 0.6 0.8
Time sec
1
1.2 1.4