# Estimating Time-Varying Applied Current in the Hodgkin-Huxley Model
## 3 Parameter Estimation and the Ensemble Kalman Filter  
Given measurements of voltage, our aim is to estimate the time-varying applied current \(I(t)\) that best fits the available data. This is a parameter estimation inverse problem, where the parameter of interest is a time-varying deterministic function with assumed unknown dynamics. More specifically, we assume here that we cannot directly measure the time-varying applied current and that we do not have equations available to explain its dynamics. The set-up for this inverse problem is similar to the standard set-up for estimating parameters in initial value problems of the form  
\[\frac{dx}{dt}=f(t,x,\theta),\qquad x(0)=x_{0} \tag{22}\]  
where \(x=x(t)\) denotes the model states and \(\theta\) denotes the model parameters [19]. Given some discrete, noisy system measurements  
\[y_{j}=G(x(t_{j}),\theta)+w_{j},\qquad 0<t_{1}<\cdots<t_{T} \tag{23}\]  
the inverse problem is to estimate the model states \(x(t)\) and parameters \(\theta\). Most classical approaches addressing this problem tend to focus on the case when the parameters are constants, i.e., when \(\frac{d\theta}{dt}=0\). In this case, however, \(\theta=\theta(t)\) and \(\frac{d\theta}{dt}\) is some unknown function. To estimate the time-varying applied current in this work, we use a version of the ensemble Kalman filter (EnKF) with parameter tracking [16; 19]. The EnKF is an extension of the classical Kalman filter adapted to work with models that are not necessarily linear or Gaussian [12; 13]. As a Bayesian statistical algorithm, the EnKF treats all unknowns as random variables with corresponding probability distributions. The filter uses a random sample to represent the current probability distribution of states and parameters, then utilizes ensemble statistics along with model predictions and observed data to update the sample at each discrete time point. While the original EnKF was implemented for state estimation, the augmented EnKF allows for simultaneous state and parameter estimation [26]. The steps of the augmented EnKF are summarized as follows. At time \(j\), the sample  
\[S_{j|j}=\left\{(x^{1}_{j|j^{\prime}},\theta^{1}_{j|j}),(x^{2}_{j|j^{\prime}}, \theta^{2}_{j|j}),\ldots,(x^{N}_{j|j^{\prime}},\theta^{N}_{j|j})\right\} \tag{24}\]  
gives a discrete representation of the probability distribution, which is then updated using a two-step process to time \(j+1\). In the first step (the prediction step), we solve the system (22) to predict the state values at time \(j+1\). In this work, (22) is the Hodgkin-Huxley model given in (18)-(21). The state prediction ensemble is computed using the equation \[x_{j+1|j}^{p}=F(x_{j|j}^{p},\theta_{j}^{p})+x_{j+1}^{p},\qquad p=1,2,\ldots,N \tag{25}\]  
where \(F\) is the solution to (22) at time \(j+1\) and \(v_{j+1}^{p}\sim\mathcal{N}(0,\mathbb{C})\) represents error in the model prediction. The predicted states \(x_{j+1|j}^{p}\) and current parameter values \(\theta_{j}^{p}\) are then placed in the augmented vectors  
\[z_{j+1|j}^{p}=\left[ \begin{array}{c}x_{j+1|j}^{p}\\ \theta_{j}^{p}\end{array} \right],\qquad p=1,2,\ldots,N \tag{26}\]  
which are used to compute ensemble statistics. The prediction ensemble mean is computed using the formula  
\[\bar{z}_{j+1|j}=\frac{1}{N}\sum_{p=1}^{N}z_{j+1|j}^{p} \tag{27}\]  
and the prior covariance matrix by  
\[\Gamma_{j+1|j}=\frac{1}{N-1}\sum_{p=1}^{N}(z_{j+1|j}^{p}-\bar{z}_{j+1|j})(z_{j +1|j}^{p}-\bar{z}_{j+1|j})^{T}. \tag{28}\]  
Note that while the parameters \(\theta_{j}^{p}\) are not updated in the prediction step, their cross-correlation information with the predicted states is embedded in the prior covariance matrix and is used in the next step to update the posterior sample. In the second step (the observation update), the predicted values are compared with the observed data \(y_{j+1}\) at time \(j+1\).