## 4 Algorithm Design
### Leak Detection Algorithm
#### 4.1.3 Final Decision Based on Improved Evidence Combination Rule
 \tag{20}\]  
According to Equation (19), \(R_{AB}(\tau)\) is an integral in a limited time range. In the practical application, data sampling only utilizes the limited part of each wave while wave amplitude of unused part is set to 0. Namely, if \(i>n\), \(a_{i}=b_{i}=0\); if \(j>0\) and \(i+j>n\), \(a_{i+j}=0\); if \(j<0\) and \(i-j>n\), \(b_{i-j}=0\). As a consequence, when \(|j|\) increases, the number of items in (19) becomes increasingly less and the amplitude of \(R_{AB}(\tau_{j})\) declines gradually. Eventually, when \(|j|>n\), \(a_{i+j}=b_{i+j}=0\) and \(R_{AB}(\tau_{j})=0\). When \(\tau_{j}=\tau^{\prime}\), \(R_{AB}(\tau_{j})\) arrives at the maximum as a result of the same phase between \(A\) and \(B\). Thus we obtain the delay time at the peak point of \(R_{AB}(\tau)\). For any functions \(A(t)\) and \(B(t)\) with a delay time \(\tau_{j}\), the cross correlation function \(R_{AB}(\tau)\) of \(A(t)\) and \(B(t+\tau)\) includes the maximum value at \(\tau_{j}=\tau^{\prime}\), so this kind of method is applicable to localization of continuous leak signals. For instance, node \(A\) receives the signal wave \(A(t)\) whereas node \(B\) receives the wave \(B(t+\tau)\) with a delay time \(\tau^{\prime}\) relative to \(A(t)\), hence leak signal arrival time difference from the leak point to upstream and downstream nodes could be acquired at the peak of \(R_{AB}(\tau)\). Namely, \(\Delta t_{AB}=\tau^{\prime}\). Equation (14) is used to calculate the position coordinates of leak point according to \(\Delta t_{\text{AB}}\), where wave velocity \(\alpha\) is also an important parameter. Practically, the spread velocity of the signal wave is affected by many complicated factors, so \(\alpha\) is determined by actual measurement in the experiment. (3) Weighted Average Localization  
All the single mode signals are divided into \(N_{P}\) pairs by signal grouping algorithm, which can generate \(N_{P}\) coordinates according to cross correlation time difference localization method. However, it may generate errors during the process of signal processing. Therefore \(N_{P}\) kinds of localization results are not quite similar. In order to minimize the interference of errors and improve the localization accuracy, weighted average localization algorithm is introduced to work out position coordinates of leak point. The localization Equation is shown as follows:  
\[P_{look}=\sum_{j=1}^{N_{P}}\mu_{j}P_{j}\qquad(1\leq j\leq N_{c}) \tag{21}\]  
where \(P_{look}\) represents the final position coordinate of leak point. \(P_{j}\) denotes position coordinate of leak point calculated by signals in pair \(j\). \(\mu_{j}\) is the weight factor, which signifies credibility of leak point position determined by signals in pair \(j\). It can be seen from signal attenuation theory and network deployment mode that the farther the distance between two sensor nodes is, the greater the attenuation of received signal is, which results in the decline of \(\mu_{j}\). Therefore, \(\mu_{j}\) is inversely proportional to the distance between two sensor nodes. To maintain the precision of final position of leak point, the sum of \(\mu_{j}\) (\(1\leq j\leq N_{P}\)) should be 1. Hence the Equation of weight factor \(\mu_{j}\) is:  
\[ \begin{cases}\mu_{j}=\dfrac{Con}{L_{j}}\\ \sum_{j=1}^{N_{P}}\mu_{j}=1\end{cases} \qquad(1\leq j\leq N_{c}) \tag{22}\]  
where \(L_{j}\) denotes the distance between two nodes in pair \(j\). And \(Con\) is a constant, which is used to assure that the sum of \(\mu_{j}\) is 1. When values of \(N_{P}\) and \(L_{j}\) are certain, \(Con\) could be acquired from the following Equation:  
\[Con=\dfrac{1}{\sum_{j=1}^{N_{P}}\dfrac{1}{L_{j}}} \tag{23}\]