# Clock Ensemble Algorithm Test in the Establishment of Space-Based Time Reference
## 2 Clock Ensemble Algorithm
### Natural Kalman Clock Ensemble Algorithm  
Both the ALGOS algorithm and the AT1 algorithm mentioned above are weighted average algorithms, the keys of which are weight and predicted value. Different weights and predicted values will result in different algorithm performances and application scenarios. Different from the weighted average algorithm, the Kalman algorithm proposed by [PERSON] in 1982 focuses on estimation. The Kalman algorithm optimizes the variance between the reference clock and the ideal clock and takes the estimated value as the correction to generate the timescale [43; 44]. The Kalman algorithm is based on a discrete and dynamic model of atomic clocks. The Kalman filter is constructed by superimposing all the single clock models in the clock group. The deviation between all clocks and reference clocks is the input, and the output is estimations of all clock phases, frequency, or frequency drift. The satellite clock data used in this paper are primarily hydrogen clocks and a few rubidium and cesium clocks. For hydrogen clocks, the Random-run frequency modulation noise (RRFM) is not obvious, and it is less affected by frequency drift [45; 46]. According to this characteristic of the hydrogen clock, and a few rubidium clocks and cesium clocks have little influence on the result of the algorithm, this paper only considers phase and frequency in the Kalman filter, not frequency drift. A clock group contains N clocks. All conform to the following model  
\[ \begin{bmatrix}x_{i}(t)\\ y_{i}(t)\end{bmatrix} = \begin{bmatrix}1&T\\ 0&1\end{bmatrix}\begin{bmatrix}x_{i}(t-1)\\ y_{i}(t-1)\end{bmatrix} + \begin{bmatrix}\xi_{i}(t)\\ \eta_{i}(t)\end{bmatrix}  \tag{1}\]  
\[Q_{i}= \begin{bmatrix}E_{i}&0\\ 0&H_{i}\end{bmatrix}  \tag{2}\]  
where \(x_{i}(t)\) represents the time deviations of all the clocks; \(y_{i}(t)\) is the frequency deviation; \(T\) is the time interval; \(Q_{i}\) is the system noise matrix; \(\xi_{i}\) is white frequency modulation (WFM), and the variance is \(E_{i}\); \(\eta_{i}\) is the random walk frequency modulation (RWFM), and the variance is \(H_{i}\). According to the Kalman filtering model, the equation of the clock group is written  
\[X(t)=\Phi X(t-1)+W(t)\]\[Z(t)=HX(t)+V(t) \tag{4}\]  
where  
\[X(t)= \begin{bmatrix}x_{1}(t)\\ y_{1}(t)\\ x_{2}(t)\\ y_{2}(t)\\ \vdots\\ x_{N}(t)\\ y_{N}(t)\end{bmatrix} \]  
\[\Phi= \begin{bmatrix}1&T\\ 0&1\\ &\ddots\\ &&1&T\\ &&0&1\end{bmatrix} \]  
\[W(t)= \begin{bmatrix}\xi_{1}(t)\\ \eta_{1}(t)\\ \xi_{2}(t)\\ \eta_{2}(t)\\ \vdots\\ \xi_{N}(t)\\ \eta_{N}(t)\end{bmatrix} \]  
\[H= \begin{bmatrix}1&0&-1&0&0&0&\cdots&0&0\\ 1&0&0&0&-1&0&\cdots&0&0\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ 1&0&0&0&0&\cdots&-1&0\end{bmatrix} \]  
\(H\) is a matrix of \(\pm\)ones and zeroes such that each row takes the difference of two-phase components of \(X\). In Kalman filtering, every clock is identical. No matter which one is selected as the reference clock, it will not affect the final result. In practice, the reference clock may have missing observations. In the filtering process, the missing value is ignored since each clock is equivalent, we can choose other clocks with observed values as reference clocks, and then the processing continues. One convention in the \(H\) matrix is to use the first clock as the reference clock. When there is a change in the reference clock, the position of \"1\" in the \(H\) matrix must be adjusted accordingly. The Kalman filter equations are described in the following  
\[\left\{ \begin{array}{l}\ddot{X}_{t,t-1}=\Phi X_{t-1,t-1}\\ P_{t,t-1}=\Phi P_{t-1,t-1}\Phi^{\prime}+Q\\ K=P_{t,t-1}H^{\prime}[H\dot{T}_{t,t-1}H^{\prime}+R]^{-1}\\ \dot{X}_{t,t}=X_{t,t-1}+K[Z(t)-H\dot{X}_{t,t-1}]\\ P_{t,t}=(I-KH)P_{t,t-1}\end{array} \right. \tag{5}\]  
where \(P\) is the error variance matrix of \(X\), \(Q\) is the noise matrix, \(K\) is the Kalman gain matrix, and \(R\) is the measurement noise covariance matrix. The value obtained by the Kalman filter is the time deviation between each clock and TA (Atomic time.