Appendix

Appendix
All linear algebra algorithms described here were taken from or derived on the basis
of the work of Eidelman and Gohberg [27].
Throughout the text we use the following notation: for matrices we use bold font, e.g.
q ; The i-th row or column of the matrices is denoted by the same letter but font is not
bold and italic, e.g. qi ; matrices that are the sum of i matrices - bold and with the
upper index i , corresponding to summation, e.g. f i . Operation a , where a is a
aij
matrix, denotes a tensor of rank 3 with elements given by aijs 
.
 s
A0
Mean and Covariance as a Function of Kinetic Model
Parameters
Let’s introduce a state probability vector p (t ) to describe the occupancy of each of
N S conformational states of a channel at time point t . Then pi (t ) is the probability
to find a channel in the state i at time point t . Now we can write down mean, E x t  ,
and covariance, c m , of the vector x (see Asymptotic Log-likelihood chapter of
Methods for definition) in terms of the state probability vector. To write an expression
for the covariance, we note that the product xt xt ' differs from zero only in the case
when the channel was open at both time points t and t ' . Thus, we have
NO
E xt    po t 
(A0.1)
o 1
NO
NO
No
No
o 1
o' 1
o 1
o 1
c m t ,t '  Ext xt'   Ext Ext'    po t  po' ,o (t' | t )   po t  po t'  (A0.2)
where po t  is the probability that the channel is in the o -th open state at time point
t,
po' ,o (t' | t ) is the conditional probability that the channel is in the open state o' at time
t' given it was in the open state o at time t ; N O is the total number of open states
in the model. Thus, for the elements of mean and covariance of the single-channel
current we have:
μt1  it xt 
c 
1
m t,t'

o No
i
o 1
o
po t 

NO
NO
o 1
o' 1
 E it xt it' xt'  μt μt'   io po t  io' po' ,o t' | t   μt μt'
(A0.3)
And for the elements of mean and covariance of the sum of single-channel currents,
mediated by N ch identical and statistically independent channels, we have:
1
NO
μt  N ch  io po t 
o 1
c m t,t'
(A0.4)
μμ
 N ch  io po t  io' po' ,o t' | t   t t'
N ch
o 1
o' 1
NO
NO
To estimate likelihood (Eq. 1 in Methods) as a function of model parameters, we need
to express po t , po' ,o t' | t  in terms of the rate constants k ij . To this end we
introduce a rate matrix [18, 20], Q  {k ij } , which is composed of rate constants
according to the following rules: each off-diagonal element, kij  lim
pij
, is equal to
t
the rate constant of the transition from the state j to the state i , if the transition is
allowed by the model. Otherwise, k ij  0 . The diagonal elements, k ii , are set to
t 0
  k ij , so the sum over each column is zero. For convenience, the matrix Q is
j
ordered so that its first N O columns and rows correspond to conducting states of the
channel.
The evolution of the state probability vector p satisfies Kolmogorov equation
p  Qp , integrating which we can write down the probability p o (t ) and the
conditional probability po' ,o (t' | t ) as
 
(t ' | t )  e
p o (t )  e Qt
p o ',o
o ,:
p(0)
Q (t 't )

(A0.5)
o ,o '
where p j 0  is the probability that the channel initial state is j . This initial state
vector can be expressed as a function of kinetic model using Eq. A0.5 provided the
concentration/voltage stimulation applied to the channels is known during sufficiently
Q t
long time preceding current registration (i.e. p(0)   e j j p(T ) ).
j
Substitution of Eqs. A0.5 into the Eqs. A0.4 gives the well-known equations for the
mean and covariance of macroscopic current as a function of a kinetic model [18]
(Eqs. 2 in Methods).
μt  N ch i T e Qt p(0)
cm t,t'  N ch i T e Qt p(0)e Q t 't i  i T e Qt ' p(0) i T e Qt p(0) 
(A0.6)
In the case of complex stimulation protocol let a kinetic model be described by
the matrix Q s during a stimulation protocol step s that lasted from time Ts 1 to time
Ts . Then the solution to the Kolmogorov equation at a time t is:
 s 1

pt   e Qs ( t Ts 1 )   e Q ν (T T 1 )  p0
  1

(A0.7)
where e Q ν t  U e D t U1 and D is a diagonal form of Q provided all eigenvalues
 are different.
It follows from this that:
2
NS
p o t    U s o, j e
s , j ( t Ts 1 )
j 1
NS
po' ,o t | t'   U s o, j e
 1  s 1 Q ν (T T 1 ) 

 p0
U s   e

   1
j
s , j ( t Ts 1 )
j 1
(A0.8)
 s 1

 (T  t ')
U s 1   e Q ν (T T 1 ) U s ' e s , j s ' U s'1  j,o'  (A0.9)
  s '1

where po ',o (t | t ' ) is the conditional probability that the channel is in the open state o
at time t given it was in the open state o' at time t' .
It follows from Eqs. A0.4, A0.8, A0.9 that in the case of a complex protocol cm is
given by:
 s (i ) 1 Q'ν (T T 1 ) 
B kj , i  j
c m ij   A ik   e

k 1
  s  j 1

c m  ji  c m ij , i  j
N S 1
(A0.10)
where matrices A , B and e Q 'ν t satisfy the following equations
Aik  e
Aik 
λs(i),k ti
NO
 i U   o,k , 1  k  N
o
o 1
t
i
N ch
s i
S
(A0.11)
, k  NS  1
NO

  U s1j  k,o'  p o' t j  io'  , 1  k  N S
 o' 1

Bkj   μt j , k  N S  1
Bkj  N ch e
e
Q 'ν t


λs(j),k Ts(j) t j
e Q νt
0
0
1

(A0.12)
(A0.13)
Thus, c m is quasiseparable matrix.
А1
Linear Algebra Algorithms for Semiseparable Matrices
Consider a symmetric semiseparable matrix c m which have constituent
|
matrices p   p j  and q  qi and diagonal matrix d ii  d i of dimensions
|
N t  ( N S  1) , ( N S  1)  N t , N t  N t , respectively.
Cholesky Decomposition
3
Assume that c m can be represented as :
cm  GDGT ,
(А1.1)
where G is lower triangular, G ij  0 , i  j , G ii  1 and D is diagonal matrix,
Dii  g i . Then G is also semiseparable with components G ij  p1i q1 j
cm ij   G ik G jk g k   p1i q1k p1 j q1k g k  p1i   q1k q1k T g k  p1 j T ,
j
j
k 1
k 1
 j
 T
T
 p1 j   q1k q1k g k  p1 j ,
 k 1

 
d j  cm
j
jj
 k 1

i, j  1 : N t , i  j
j 1
g 1  d1
(А1.2)
Since c m ij  pi q j it is clear that the matrix G is indeed semiseparable with
components p1i and q1i given by equations:
p1i  pi
f j p1 j  q j
T
(А1.3)
 j

T
f    q1k q1k g k 
 k 1

j
This yields that the matrix f j can be calculated recursively
f j  f j1  q1j q1Tj g j
(A1.4)
Taking into account that G jj  1 , recurrent relations for q1 and g then follow from
Eq. А1.3 and А1.4,
q1 j 
q j  f j 1 p Tj
gj
,
g j  d j  p1 j f j 1 p1Tj ,
N  j 1
N  j 1
(A1.5)
g 1  d1
Equations А1.4, А1.5 give an algorithm for computing Cholesky factorization of a
semiseparable matrix.
4
Solution of a System of Linear Equations
Calculation of log-likelihood also includes procedure of solving the system of
equations which has the form (Eq. 11 in Methods)
y  Gx
(A1.6)
where G is lower triangular and semiseparable matrix of coefficients, x and y are
Nt  N matrices. To solve this system, we obtain recurrent relations similar to Eqs.
А1.4, А1.5. Indeed,
i
 i 1

yi   G ij x j   p1i q1 j x j   G ii xi  p1i z i 1  xi
j 1
 j 1

i
(А1.7)
z i   q1 j x j  z i 1  q1i xi
j 1
where x j , yi stand for the row-vector of the length N and i, j  1 : Nt . Eq. А1.7 yields
xi  yi  p1i z i 1 ,
i 1
(A1.8)
x1  y1
For the system of equations with the upper triangular and semiseparable matrix of
coefficients
y  GT x
(A1.9)
the relations similar to Eq. A1.7 are
yi 
~
zi 
i
 G Tij x j 
j  Nt
i 1
 q1 x
j  Nt
j
i
i 1
j  Nt
j  Nt
 G ji x j   q1 j p1i x j  G ii xi  p1i ~z i 1  xi
 q1i xi  ~
z i 1  q1i xi
j
and they yield recurrent relations
xi  yi  p1i ~z i  1 ,
~z i  ~z i  1  q1 x ,
i
i
i  Nt
i  Nt
(А1.10)
xN t  y N t
~z N t  q1 x
Nt Nt
Computing log-likelihood of the set of ion-channel currents, we have to deal with
semiseparable matrices whose constituent vectors have the form
5
pi  p ' i  e  t i
T
(A 1.11)
qi  q'i  e  ti
Here  denotes Hadamard multiplication, i.e. elementwise matrix multiplication,  is
a column-vector composed of eigenvalues of Q (see A0). For large t i it is impossible
to represent such elements as a floating point numbers. To address this problem we
have modified algorithms А1.4, А1.7, А1.10, so that matrices p' and q ' appear in
them instead of matrices p and q . Indeed, it is easy to check that the algorithm А1.7,
А1.8 can be represented as


z1 i  z1 i 1  q1'i xi  exp t   1TN

xi  yi  p1'i z1 i 1 , i  1
(А1.12)
x1  y1
where z1 i  z i  exp ti 1   1TN  , 1 N is a vector of the size N , whose elements are
ones, so that exp t  1TN is N S  N matrix and ti  it .
The algorithm А1.10 is represented as
xN  y N



z1 i  z1 i 1  q1'i 1 xi 1  exp  t   1TN , i  N
(A1.13)
xi  yi  p1'i z1 i , i  1
The algorithm expressed in Eqs. А1.4, А1.5 is represented as


f1 j  f1 j1  q1' j q1' j  g j  exp t   exp t 
T
T
g j  d j  p1' j f1 j1  p1' j  , N  j  1

T
g1  d1
q ' j f1 j1  p ' j 
T
q1' j 
gj
,
N  j 1
(A1.14)

where f1 j  f j  exp  j  1t   exp  j  1t 
T

Next, we consider few additional operations with semiseparable matrices, which
allow for efficient computation of the log-likelihood gradient.
Symmetric Semiseparable Matrix Inversion
First, consider the problem of finding G inverse. This matrix is a solution of the
system GG 1  Gx  E where E is identity matrix. Because G is lower triangular
6
and G jj  d j  1 , we try the solution of the above equation in the form of a lower
triangular matrix: xij  0 for i  j , x jj  1 . Thus,
i 1
 p1 q1 x
k j
i
k
kj
 di xij  y ij  0 for
i j
(A1.15)
Therefore,
i 1
xij   p1i q1k xkj
(A1.16)
k j
For x i 1, j we have
i 1
i 1
k j
k j
xi 1, j   p1i 1  q1k xkj  p1i 1 q1i xij   p1i 1 E  q1i p1i  q1k xkj
(A1.17)
Continuing transformation, we obtain
xi 1, j   p1i 1 E  q1i p1i E  q1i 1 p1i 1 E  q1 j 1 p1 j 1 q1 j
(A1.18)
Therefore, G 1 is a lower triangular matrix and it can be represented as
{G 1}ij  p 2i ai 1ai  2 ...a j 1q 2 j
{G 1}ii  d 2i  1
,
(А1.19)
where p 2   p1 , a i  E  q1i p1i , q 2  q1
The matrix whose off-diagonal elements are given by Eq. А1.19 (with arbitrary
matrices a i and diagonal elements) is called quasiseparable. Thus, G 1 is
quasiseparable.
Now we find the matrix c m1
{cm1}ij 
 NT 1

1
1
1
1
1
1
  g k p 2k a2ki q 2i p2k a2k ,i 1 a2ij q2 j  p 2i a2ij q2 j gi1
{
G
}
{
G
}
g

{
G
}
{
G
}
g


ki
kj k
ij
ii i
k  i 1
 k i 1

NT
where a2ij  ai 1ai  2 ...a j 1 and the following relations hold: a2ij  a j 1a2i ( j 1) ,
a2( i 1) i  E
The first term on the right side can be rearranged so that the equation appear as
{cm1}ij  p3i a2ij q2 j  p2i a2ij q2 j gi1  p5i a2ij q2 j
where
7
(А1.20)
NT

1
T
1
T


p
4
q
2
p
4
g
a

q
2

ki
i
ki k
i
i   g k p 4 ki p 4 ki a i ,
k  i 1
 k  i 1

1
p 4ki  p 2k a2ki ,
p5i  p3i  p 2i g i
NT
p3i 
(А1.21)
We introduce auxiliary variable matrix
f i 1 
NT
g
k i 1
1
k
p4Tki p4 ki
(А1.22)
so that
p3i  q 2Ti f i 1a i
(А1.23)
It satisfies the following recurrent relations
fi  gi1 p 2Ti p 2i 

NT

 gk1 ( p2k a2ki ai )T p2k a2ki ai  gi1 p2Ti p2i 
k  i 1
 g a
NT
k  i 1
1
k
T
i
T
 gi1 p 2Ti p 2i  ai fi 1ai
T
f N T  g N1T p 2TN T p 2 N T
After substitution of a i , we have the recurrent equation for f :
fi  gi1 p2Ti p2i  fi1  pqf   pqf   pqfqp
T
(А1.24)
where
pqf  p1Ti q1Ti f i 1
pqfqp  p1Ti q1Ti f i 1q1i p1i
As one can see from Eqs. А1.20, А1.24, cm1 is symmetric quasiseparable matrix
c 
1
m ij
   c  , i  j, c 
 p5i a2ij q5 j , cm1
1
m ji
ij
1
m ii
 d 5ii
with components given by recurrent equations
q5  q1
p5i  p 2 i g1i  q1i f i 1  q1i f i 1q1i p1i
T
d 5i  g1i  q1Ti f i 1q1i
T
,
(А1.25)
p5 N  p 2 N g1N
d 5 N  g1N
8

a2ki p 2Tk p 2k a2ki ai 
where g1  g 1 .
Calculation of Trace of the Matrix Product
Another useful operation is the operation of the form – Tr F  C , where F symmetric N t  N t semiseparable or quasiseparable matrix, C - symmetric
semiseparable matrix of the same size with components A , B and diagonal d .
We first consider semiseparable F . In this case the above operation can be
represented as:
NT
Tr F  C  2Tr (H  B)   Fkk d k
(А1.26)
k 1
where H is N t 1  N S matrix.
Let prove the equality А1.26. Let
Fki  Fik  pk qi
(А1.27)
Then
Nt
Nt
Nt
Tr F  C   Fik C ik   Fkk d k 
k 1 i 1
Nt
  Fkk d k 
k 1
Nt
N t 1 N t

k 1
N t 1 N t
 F
i 1 k  i 1
ik
C 
N t i 1
 Fik C ik   Fik C ik 
i 1 k  i 1
i  2 k 1
N t 1 N t
ik
 F
k 1 i  k 1
ik
Nt
C  Fkk d k 
ik
k 1
N t 1 N t
  F
i 1 k  i 1
ik
 Fki C ik
Nt
N t 1
 Nt

ik


F
C

F
d

2
p



ik
kk k
k   q i Ai  B k 
k 1 i  k 1
k 1
k 1
 i  k 1

N t 1 N t
Tr F  C   Fkk d k  2 
k 1
Nt
N t 1
k 1
k 1
  Fkk d k  2  H k Bk
(А1.28)
Matrix H can be evaluated recursively:
H i  pi z i , i  N t
z i  z i 1  qi 1 Ai 1 , i  N t
(А1.29)
z Nt  0
Stabilization of these calculations is similar to Eq. А1.14, provided that all
eigenvalues of the matrix F are zero.
9


H 1i  H i  exp  T ti , i  N t
z1   z1
i
i 1
jk
 qi 1 A'i 1

jk
exp( k t ) , i  N t
z1 N t  0
(А1.30)
H 1i  pi z1 i , i  N t
Nt
N t 1
k 1
k 1
Tr F  C   Fkk d k  2  H 1k B1k
   z 
Here and z1 i
Ai  A'i  e
T
i
jk
jk
exp  k ti  or z1i  zi  exp( T ti ) and A'i , B'i are given by
ti
(A1.31)
Bi  B'i  e   t i
In the case when F is quasiseparable matrix, by analogy with Eq. А1.28 we have
Nt
Nt 1
Nt
Nt 1
 Nt

Tr F  C   Fkk d k  2  qkT   a2Tik piT Ai  Bk   Fkk d k  2  H k Bk
k 1
k 1
k 1
k 1
 i k 1

(А1.32)
and matrix H is again evaluated recursively:
z Nt  0
z k  aTk 1z k 1  pkT1 Ak 1 , k  N t
(А1.33)
H k  qkT z k , k  N t
Stabilization of these calculations could be done in the same way as it was done for
Eq. А1.30, provided that eigenvalues  are the same for F and C (this is indeed the
case for the matrices that appear in the equations for the log-likelihood gradient):

H 1 j  H j  exp  T t j

H 1N  0
z1   a'
i
jk
i 1
z1 i 1  p'Ti1 Ai 1

jk
exp(  j t  k t ) , i  N
H 1i  q'Ti z1 i , i  1
Nt
N t 1
k 1
k 1
Tr F  C   Fkk d k  2  H 1k B1k
Where p'i , q'i A'i , B'i are given by
10
(А1.34)
p i  p ' i  e  ti
T
q i  q ' i  e   ti
(A1.35)
Ai  A'i  e  ti
T
Bi  B'i  e  ti
   z1 
and zi
i
jk
jk
exp  ( jti  k ti ) , ai jk  a'i jk exp   j ti  k ti 
А2
Log-likelihood Gradient
Consider Eq. 20 of Methods
 log L  

  
 



T
T
1 N
N
 2  I c m1 I1i:Nt  I  I1i:Nt  I c m1c m c m1 I1i:Nt  I   log det c m 

2 i 1
2
(А2.1)
It can be represented in the form
1
 log L   ( F1  F2  F3  F4  F5 )
2
(А2.2)
where F1 , F2 , F3 , F4 , F5 satisfy the following equations (we keep in mind that
Tr ( AB )  Tr (BA) , Tr (A T )  Tr (A) and log(det( A))  Tr (log A) ):
N

 I
i 1
i
1:N t

T
1
m
1
m m
 I c c c

F1  Tr c 2cT2 c1m
I
i
1:N t


T


T I I

 I  Tr c c c  Tr c 2 c 2 

 N ch


T
2 2
1
m


T

I I 

c   c m 

N ch 

T




T I I

   Tr  c cT  I I
F2  Tr c 2 c 2 

 N ch  
 2 2 N ch




1
m


  F  F
1
2


(А2.3)
(А2.4)
(А2.5)
  
T
I  I 
T
c c
T
2 2
N ch

  2 I



T

I 

  c 2 cT2

N
ch 

(А2.6)

c2  c m1 I1i:Nt  I
i
N


  

(А2.7)
 
F3    2  I c m1 I1i:Nt  I  2  I M 1
i 1
T
T
11
(А2.8)
N


N
M 1  c m1  I1i:Nt  I   c2i
i 1
(А2.9)
i 1


N log det c m   NTr c m1c m  F4  F5

F4  NTr c m1 c 1m
 
F5  2  I
T
(А2.10)


NI 

  c m1

N
ch 

(А2.11)
where  in Eq. A2.6 denotes scalar multiplication, cm is given by Eq. 20 of Methods
and c1m is given by
c    A~ B~  A
c   c  , i  j
NS
1
m ij
ik
k 1
1
m ji
kj
ik

B kj , i  j
(А2.12)
1
m ij
(А2.13)
~
~
where matrices A and B are equal to the matrices A  p and B  q from Eqs. 18 of
Methods without last N noise  1 columns and rows, respectively (see also Eqs. A0.1013).
The calculation of F1 using Eq. А2.4 is reduced to the operation of the form Tr F  C
with C  c1m and N t  N t symmetric semiseparable F  c 2 c 2 . The calculation of
F4 using Eq. А2.11 is reduced to the same operation but with N t  N t quasiseparable
T
1
F  c m . As we proved earlier, both operations are represented as
Nt 1
~ Nt
Tr F  C  2  H k Bk   Fkk d k
k 1
k 1
and keeping in mind that C is identically equal to c1m , using A2.12 we write


Nt 1
Nt
~
~
Tr F  C  2  Ak  H Bk  H Ak  Bk   Fkk d k
k 1
(А2.14)
k 1
where H B is a N S  N t matrix and H A is N t  N S matrix, d k  c1m kk . H A and
H B can be calculated recursively (A1, Eqs. А1.29, A1.33 and ultimately used
stabilized algorithms A1.30, A1.34). It is reasonable to perform calculations using Eq.
А1.30 simultaneously with evaluation of c 2 (solving the system

  
T
c2i  cm1 I1i:N t  I  G 1 C1i:N t with the help of the algorithm А1.10, see also Eqs. 911 in Methods), because matrices z i that appear in Eqs. А1.30 and А1.10 coincide in
this case.
~
It will be shown that the components of A are equal to zero for all parameters
instead of the case when the differentiation is done with respect to the components of
the vector  . This case will be considered separately.
12
For the other parameters, Eq. А2.4 is reduced to evaluation of the trace of product of
~
N t  N s matrix H 0 by the tensor B :
 Nt  N
F1      c2i
 k 1  i 1
   d
2
k

k
N t 1
~ 
 2  H 0k B
k
k 1

(А2.15)
Similarly, F4 (Eq. А2.11) is estimated using Eqs. А1.24, А1.25 from A1
Nt 1
 Nt 1
~ 

F4  N  {c m }kk d k  2  H1k B
k 
k 1
 k 1

(А2.16)
Introducing additional variables:
H 2  H 0  NH1
H 3  c 2 (cT2
(А2.17)
I
NI
)  M 1  c m1
N ch
N ch
(А2.18)
from Eqs. A2.2, A2.15, A2.16, A2.17, A2.18 we have:
 log L
1  Nt  N
       c2i ,k
2  k 1  i 1
 s
 
2
~
Nt 1
Nt 1
I k 
 s
k Bk

 N{c } d k  2  H 2
 2  H 3k
 s
 s 
k 1
k 1

(А2.19)
1
m kk
To calculate B and  I it is convenient to introduce auxiliary variables a and b :
NS
aoi  Uo, i  U 1 i, j  p j 0
(А2.20)
j 1
bo 'ok  Uo, k U
1
k , o'
where U is the matrix composed of the rate matrix eigenvectors and p j 0  is initial
state probability vector (see A0 and Eqs. 18 in Methods).
Therefore, we have
NS
NS
NS
i 1
j 1
i 1
po t    e it Uo, i  U 1 i, j  p j 0   e it aoi
NO
I (t )  N ch  io po t 
o 1
13
(А2.21)


NO
NO
NO
NO
~
 t
 t
B kj  N ch e k j  io ' po ' t j  io Uo, k U 1 k , o'  N ch e k j  io ' po ' t j  io bo 'ok  
o '1
 N ch e
k t j
 i  e
NO
o '1
NS
o'
o 1
i t j
i 1
o '1
 i b
NO
ao 'i
o 1
o o 'ok
,
o 1
1  k  NS
(A2.22)
Let introduce a new parameter vector  N  N ch , io , a, b,   instead of the model


parameter vector   k , i, N ch (see Methods, The Model of a Macroscopic
Current). The log-likelihood gradient with respect to  N can be easily computed:
 I t  NO

:
  io po t  ,
N ch N ch o1
~
B kj
~
A ik
0,
N ch

N ch
~
B kj
N ch
(А2.23)
~
~
B kj
A ik
  I t 
 t 
 N ch e k j  po t j
:
0,
 N ch po t  ,
io
io io
io

  i b    i

 I t 
 t
:
 N ch i e  ,
a a
~
B kj
~
A ik
0,
a
NO
o ' oo'k
o '1
 N ch e
a
NO
k t j
i e
 t j
o '1

po ' t j bo 'ok 

(А2.24)
o'
NO
 i b 
o 1
o
ok
(А2.25)

 I t 
 0,
:
b b
~
A ik
 0,
b
~
B kj
b
  k N ch e
 t j
 N S it j 
i   e ai i
 i 1

(А2.26)
~
A
Thus for all  i except the components of vector  it appears that
 0 and,
 iN
therefore, in Eq. А2.14 H   0 . In this case log-likelihood gradient is calculated
using Eq. А2.19.
N
Consider the derivatives of log-likelihood with respect to the components of vector
:
c1m ti , t j 


NO
 N S  t t   t
 N ch  io '   e k i j t j e  j ao '
o '1
 k 1
 i b
NO
o 1
o
NO

o 1

 t t 
po ' t j  io bo 'o   Q 2  Q1  Q 0 ij
o 'ok   t i  t j e

i
j
(А2.27)
    A~
where cm
NS
1
ij
k 1

NS
NO
NS
~
 t
k ti k t j
B

N
e
e
i
 o'  e m j ao'm
ik kj
ch 
k 1
o '1
where
14
m1
i b
NO
o1
o o 'ok

Q 0 ij  N ch  io 'ti e  t t  po ' t j  io bo 'o 
NO

NO
i
j
o '1
o 1
Q 1 ij   N ch  io't j e  t t  po ' t j  io bo'o 
NO

NO
i
j
o '1
(А2.28)
o 1
Q 2 ij  N ch  io'  e  t t  t j e  t ao '  io bo 'ok 
NO
NS
k
o '1
i
j
 j
k 1
NO
o 1
2
Since F1  F4   Tr F  Q i  , where F  c 2cT2  Ncm1 , i  {0,1,2} , then consider, one
i 0
by another,  i  Tr F  Q i  .
1) According to Eqs. А1.28, А1.32, А2.15, А2.16  0 can be represented as
Nt
 N
 0      c2i ,k
k 1 
i 1
 
2
N t 1

~
 {c m1 }kk d k0  2  H 4,k Bk
k 1

(А2.29)
 Nt
 Nt
~ 
~ 
Where H 4,k  c2,k   c2T,i Ai ti   q5Tk   a2ik p5Ti Ai ti  and p5 , q5 , a2  i k 1

 i k 1

1
components of the matrix c m
Matrix H 4 can be calculated recursively (using Eqs. А1.29, А1.33, replacing A by
~
A t ):
H 4  H'4 H' '4
(А2.30)
H ' 4, N  0
~
z1i  z1i 1  qi 1 Ai 1ti 1 , i  N
(А2.31)
H '4,i  pi z1 , i  1
i
H ' ' 4, N  0
~
z1i a i 1 z1i 1  p5Ti1 Ai 1t i 1 , i  N
(А2.32)
H ' ' 4,i  q5i z1i , i  1
T
Stabilization of these calculations is done in the same way as it was done for Eqs.
А1.30, A1.34
2) 1 is estimated by Eqs. А2.15, А2.16:
Nt
 N
Φ1      c2i , k
k 1 
i 1
 
2
N t 1

 {cm1}kk d k1  2  H 2, k Bk1
k 1

15
(А2.33)
NO
where B1 ,t   N ch  io ' te
 t
o '1
NO
po ' t  io bo 'o 
o 1
3)  2 can be represented as
 2,
 N
     c2i ,k
k 1 
i 1
 
Nt
2
Nt 1
 2
 {c } d k  2 N ch 
t 1

1
m kk
 i  H te
NO
o '1
NS
o'
k 1
2,k ,t
 t
 i b 
NO
ao '
o 1
o o 'ok
(А2.34)
This results in the expression for log-likelihood gradient with respect to the
components of the vector  :
N t 1
I
 log L
1 2
    Φi ,  2  H 3,k k

2  i 0

k 1




(А2.35)
where:
NO
Ik
 tk  io 'ao ' e t k

o ' 1
(A2.36)
To find the log-likelihood gradient with respect to the parameters  (instead of  N )
in this work we make use of equation
 log L

 j
where
 log L  iN

N
 j
i 1  i
N
N
(А2.37)
 iN
was estimated as follows:
 j
N
N
 iN  i 1 ,... j   ,...   i  


 j
(А2.38)
Let us estimate the number of elementary operations required for estimation of the
log-likelihood gradient. Evaluation of all matrices Hi , i  {1,2,3,4} using Eqs. А1.29,
А1.33, А2.30-32 requires approximately 4 N S N T N  2 N S2 N T operations. The size of
the vector  N is N O2  N O  1N S  N O  1. Evaluation of the log-likelihood gradient
with respect to variables b requires about ( N O  1) N S N T operations, with respect to
a - ( N O  3) N S N T , with respect to i - 3( N S  1) N O N T , with respect to  3( N O  1) N S  2 N O  1NT and with respect to N ch - ( N S  1) N T operations.
16
Calculation of
 iN
with Eq. А2.38 requires ~ N S3 N  operations. Thus, for models
 j
with relatively small number of open states, which means that N O is not very large
N
( N O  ), the time for computing matrices H i will mainly limit the log-likelihood
2
gradient computation time.
Summing up, the log-likelihood gradient computation is approximately 2 times slower
then the computation of the log-likelihood itself.
А3
Log-likelihood Calculation in the Case of Complex Protocol
Since in the case of complex protocol covariance matrix satisfies the equation
N S 1

s ( i ) 1
cm ij   A ik   e K ' (T T


 1 )
  s  j 1
 c m ij , i  j
k 1
cm ji

B kj , i  j


(А3.1)
(Eqs. A0.10-13), then it is quasiseparable (see А1.19), i.e. its elements can be
represented as
{c m }ij  pi a i 1a i 2 ...a j 1q j , i  j
{c m } ji  {c m }ij , i  j
(А3.2)
{c m }ii  d i
where a i  E for i  s1 , s 2 ,...s N stim , a i  e K'i (Ti Ti 1 ) for i  s1 , s 2 ,...s N stim , where E is
identity matrix. To solve the problem of representation of the components of matrices
p and q via floating–point numbers it is convenient to use matrices p ' and q ' , such
that:
  t  
p'i  pi  exp     i T 
  T  
  t  
q'i  qi  exp    i T 
  T  
instead of matrices p and q . In this expressions x mean integer part of x and T
should be selected such that all elements of p ' and q ' would be bounded by the limits
of floating-point number representation.
It is easy to make sure that cm can be represented as:
17
{cm }ij  p'i ai 1ai  2 ...a j 1q' j , i  j
{cm } ji  {cm }ij , i  j
(А3.3)
{cm }ii  di
where ai  diag exp T  for i such that mod( ti , T )  0 , a i  e K'i (Ti Ti 1 ) for
i  s1 , s 2 ,...s N stim  and a i  E for all others i . Analogous scheme of calculations is
applicable for the case of simple protocol.
Cholesky decomposition of quasiseparable c m matrix (А1.1) is done similar to that
of semiseparable c m (Eqs. А1.2-А1.5):
j
j 1
k 1
k 1
cm ij   G ikG jk g k   p1i a2ik q1k p1 j a2 jk q1k g k  g j p1i a2ij q1 j ,
cm ij
i j
  j 1

T
 p1i a2ij 1  a2 jk q1k p1 j a2 jk q1k g k  g j p1i a2ij q1 j  p1i a2ij  a j   a2 jk q1k a2 jk q1k  g k  p1Tj  g j q1 j
k 1

  k 1
j 1
 j 1

T
d j  p1 j   a2 jk q1k a2 jk q1k  g k  p1Tj  g j ,
 k 1

g1  d1
j 1
(А3.4)
Therefore,
p1  p
 j 1
 T
T
q j  a j   a2 jk q1k a2 jk q1k  g k  p1 j  g j q1 j
 k 1

(А3.5)
 j 1

T
matrix f j    a2 jk q1k a2 jk q1k  g k  satisfies recurrent equation
 k 1

f j  a j 1f j 1aTj1  q1 j 1 q1Tj1 g j 1
(А3.6)
Similar recurrent relations hold for g and q1
g j  d j  p j f j p1Tj
q1 j 
q j  a j f j p1Tj
(А3.7)
gj
For i  s1 , s 2 ,...s N stim  these recurrent relations are equivalent to relations А1.4-1.5
The system of equation А1.6 with matrix G being quasiseparable is reduced to a
system of recurrent relations
18
Nx
 i 1

yi   G ij x j   p1i a2ij q1 j x j   G ii xi  p1i z i 1  xi
j 1
 j 1

i
z   a2ij q1 j x j  ai 1z
i
i 1
j 1
(А3.8)
 q1i xi
xi  yi  p1i z i 1 , i  1
(A3.9)
x1  y1
These relations are equivalent to А1.7-А1.8 for i  s1 , s 2 ,...s N stim .
Algorithms А3.6-7 and А3.8-9 are used when calculating log-likelihood using Eqs. 911 of Methods.
Calculations of the likelihood logarithm gradient can be done similarly to the case of
simple stimulation protocol.
Indeed after differentiation of Eq. A3.1 we obtain:
N S 1

s ( i ) 1
c m ij   A ik   e K ' (T T
 s  j 1
 c m ij , i  j
k 1
c m ji


 1 )
N S 1
N S 1

 s (i )1

 s (i )1

B kj   A ik   e K ' (T T 1 ) B kj   A ik   e K ' (T T 1 ) B kj , i 





k 1
k 1

 s  j 1

 s  j 1

(A3.10)
In the case when F and C are quasiseparable matrices, by analogy with Eq. А1.23
we have
Nt
Nt 1
Nt
Nt 1
 Nt T T

Tr F  C   Fkk d k  2  qkT   ~
a2ik pi Ai a2ik  Bk   Fkk d k  2  H k Bk (А3.11)
k 1
k 1
k 1
k 1
 i k 1

and matrix H is again evaluated recursively:
z Nt  0
zk  ~
akT1z k 1a k 1  pkT1 Ak 1 , k  N t
(А3.12)
H k  q z , k  Nt
T
k
k
Stabilization of these calculations could be done in the same way as it was done for
Eq. А1.30. Thus, similarly to Eq. A2.14 we have


N t 1
Nt
~
~
~
Tr F  c1m  2  Ak  H Bk  H Ak  Bk  H   Bk   Fkk d k


k 1
(A3.13)
k 1
where H  is a tensor of rank 3 which appeared as result of application of the Eq.
A3.11-A3.12 to the last term of Eq. 3.10. Finally, similarly to Eq. 2.19 we have:
19
 log L
1  Nt  N i
      c2 , k
 s
2  k 1  i 1
 
2
~
~
Nt 1
Nt 1
Nt 1
 k B
Ak k 
 s
k I k
k


 N{c } d k  2   H 2 A

H 2B   2 H3
 2  H 2k ,s
 s  s
 s
k 1 
k 1
k 1


(A3.14)

1
m kk
 log L
for all terms of Eq 3.14 except the last term can be done
 s
similarly to the calculations in the case of simple protocol as it is described in A2, and
they take approximately the same number of elementary operations. To efficiently
calculate last term in Eq. A3.14 differentiation should be done with respect to the
elements of matrix as for each time moment ts when stimulation changes. Then using
Eq. A3.11 the last term in Eq. A3.14 can be represented as a sum of two terms of the
form (these terms match the terms of Eq. А2.17 ):
Then calculation of
N t 1
Nt
k t s 1 

 Nt
 Nt T T

a

Tr  F  s C    Fkk d k  2  qkT   ~
a 2 ik pi Ai a2 is ss a2 sk  Bk   Fkk d k  2  qkT  ~
a 2T( s 1) k  z rs  a2 s
 a
 k 1


arj
k 1
k 1
k 1
rj


 i k 1

(A3.15)
 
Calculation of the last term of Eq. A3.14 using Eq. A3.15 requires an order of
2
N t N S N  2 N S2 N stim  N s3 N stim
elementary operations (without accounting for
z s calculation and performing the calculations in the order, marked by parentheses). If
Nt , N  N s , N stim , then the maximal number (it depends on the exact form of the
complex stimulation protocol) of operations required for the gradient computation is
2
. Thus the complexity of the  log L estimation
N log L  Nlog L (2  Nstim / 2)  Ns3 Nstim
additionally increases approximately on N log L N stim / 2 operations compared to the
complexity of  log L computation in the case of the simple protocol.
А4
Method Implementation
Algorithms for the estimation of the log-likelihood and its gradient and the
macroscopic current generator, described in this work, were implemented in
MATLAB (except the algorithm for the log-likelihood gradient calculation in the case
of complex protocol of stimulation (A3), described by Eqs.A3.10-3.15. Currently, in
the case of complex protocol the log-likelihood gradient has been estimated as a sum
of log-likelihood gradients for simple protocols, which are the components of a
complex protocol). Source codes are freely available at:
http://code.google.com/p/multi-channel-data-analysis/.
20
 
A5
Comparison of Different Algorithms for the Log-likelihood
Evaluation
To compare the efficiency of our and Kalman filter based methods for the loglikelihood evaluation, we conducted a series of computational experiments. A set of
200 macroscopic currents, 2000 points each, was generated using the brief stimulation
protocol and the standard 7-state GABAA receptor model [30]). The log-likelihood of
this set of currents was evaluated using 3 different algorithms: Kalman filter based
algorithm implemented in MATLAB, Kalman filter based algorithm implemented in
C and our algorithm implemented in MATLAB. Models of larger sizes, taken for the
log-likelihood estimation, were obtained by concatenation of the 7-state model [30]
with a random diagonal matrices of different sizes.
Time (s), required for one evaluation of the log-likelihood of 200 macroscopic
currents 2000 points each depending on the number of states in the ion channel model.
Model
size
7
10
15
20
30
40
50
60
6.1
6.7
9.5
11
17
26
40
57
1.57
1.67
3.16
3.85
7
12
19
29
0.082
0.089
0.101
0.121
0.142
0.179
0.220
0.263
Algorithm
MATLAB, Kalman filter
*
C, Kalman filter **
MATLAB,
Semiseparable
representation
of the covariance matrix
*
- Custom implementation of the Kalman filter based recursive algorithm [22].
- State Space Models Toolbox for MATLAB (http://ssmodels.sourceforge.net/) was
used for the implementation of the Kalman filter based algorithm [22].This open
source software created by Jyh-Ying Peng supports model construction with
MATLAB objects and efficient Kalman filter backend implemented in C.
**
21