# Research on Distributed Autonomous Timekeeping Algorithm for Low-Earth-Orbit Constellation
## 3 Methodology
### D-Kpw (Control) Algorithm  
Allan variance is widely employed to assess the stability of a clock, typically using a sampling time of 10,000 s as a demarcation point. An Allan variance with a sampling time less than 10,000 s indicates short-term stability, while an Allan variance with a sampling time exceeding 10,000 s signifies long-term stability. Figure 3 presents the framework of the D-KPW (Control) algorithm, which divides the measured data into two groups according to the long-term stability characteristics. The Euclidean distance of the vector composed of Allan deviations with a sampling period longer than 100,000 s is defined as the evaluation factor, which represents the long-term stability of the satellite clock. The smaller the value is, the better the long-term stability is. The formula to calculate this quantity reads as follows:  
\[D_{i}=\sqrt{\sum\limits_{\tau>1\times 10^{5}}{\sigma^{2}}_{i}(\tau)} \tag{19}\]  
where \(D_{i}\) is the evaluation factor of satellite \(i\), and \(\sigma^{2}_{i}(\tau)\) is the Allan variance of satellite \(i\) at sampling time \(\tau\).  
A total of N data groups participate in the calculation, sorted in descending order of \(D_{i}\). The first L groups are selected to form clock ensemble 1, while the remaining N-L groups form clock ensemble 2.  
Clock ensemble 1 is used to establish the time reference \(TA1\) with better short-term stability, so \(\sigma_{i}^{2}(1000)\) is used to calculate the weights. The formula is as follows:  
\[TA1(t) =\sum\limits_{i=1}^{L}w_{1i}(t)(\widetilde{x}_{im}(t)-\hat{x}_{ie}(t)) \tag{20}\] \[w_{1i}(t) =\frac{1/\sigma_{i}^{2}(1000)}{\sum\limits_{i=1}^{L}1/\sigma_{i}^ {2}(1000)}\]  
where \(\widetilde{x}_{im}(t)\) is the result of the Kalman filtering for the clock error between a satellite \(i\) and the primary satellite in clock ensemble 1, and \(w_{1i}(t)\) is the weight of satellite \(i\) in clock ensemble 1. Other parameters have the same meaning as in Equation (2).  
Clock ensemble 2 is used to establish the time reference \(TA2\) with better long-term stability, so \(\sigma_{i}^{2}(10^{5})\) is used to calculate the weights. The formula is as follows:  
\[TA2(t)=\sum\limits_{i=L+1}^{N}w_{2i}(t)(\widetilde{x}_{im}(t)-\hat{x}_{ie}(t)) \tag{21}\] \[w_{2i}(t)=\frac{1/\sigma_{i}^{2}(10^{5})}{\sum\limits_{i=L+1}^{N }1/\sigma_{i}^{2}(10^{5})}\]  
where \(\widetilde{x}_{im}(t)\) is the result of Kalman filtering for the clock error between a satellite \(i\) and the primary satellite in clock ensemble 2, and \(w_{2i}(t)\) is the weight of satellite \(i\) in clock ensemble 2. Other parameters have the same meaning as in Equation (2).  
\(\Delta(t)\) is the clock error between \(TA1\) and \(TA2\), calculated as follows:  
\[\Delta(t)=TA1(t)-TA2(t) \tag{22}\]  
The real-time difference between \(TA1\) and \(TA2\) is estimated by the Kalman filter to obtain \(\hat{\Delta}(t)\). The \(TA1\) is modified by \(\hat{\Delta}(t)\), and the time reference \(TA\) of the system is established. The established \(TA\) can achieve the same short-term noise characteristics as \(TA1\) and the same long-term drift characteristics as \(TA2\).  
Figure 3: D-KPW (Control) algorithm framework.