# Blind Recognition of Forward Error Correction Codes Based on a Depth Distribution Algorithm
## 4 Depth Distribution Algorithm Based on Linear Block Codes
### The Algorithm of Code Length Recognition
In the same way, when \(n\
eq n_{0}\) or \(n=n_{0}\), and \(\widetilde{x^{\prime}}\) is a linearly independent column vector, the formula is:  
\[P(\widetilde{x^{\prime}_{i}}=0)=P(\widetilde{x^{\prime}_{i}}=1)=\frac{1}{2} \tag{7}\]  
In Formula (7), \(N_{j}\) satisfies a binomial distribution \(B(M,1/2)\). Let \(\psi(j)=2N_{j}/M,1\leq j\leq n\) For all possible code word lengths \(n\), the code sequence is shifted and the matrix established by each shift is denoted as \(X(n,d),0\leq d<n\). Defining judgment thresholds \(\beta\), if there are several columns in \(\widetilde{X}(n,d)\) which make \(\psi(j)\leq\beta\), we can prove that the corresponding columns in \(X(n,d)\) are linearly dependent, which is shown as:  
\[\varepsilon_{n,d}=Card(\{j\in\{1,2,\cdots,n\}/\psi(j)\leq\beta\}) \tag{8}\]  
In Formula (8), \(Card()\) represents the cardinality of a collection. For every possible code length \(n\), the sum of the \(n\) shifts is \(\varepsilon_{n,d}\), and the normalization is carried out. The formula is as follows:  
\[\widetilde{\varepsilon_{n}}=\frac{\sum\limits_{d=0}^{n-1}\varepsilon_{n,d}}{n ^{2}} \tag{9}\]  
Figure 2: Low triangle matrix after Gauss elimination. By analyzing the above formulas, it can be seen that when \(n=\alpha n_{0}(\alpha\in N^{+})\), \(\widetilde{e}_{n}\) is going to have a maximum. The \(n\) at the first maximum value is recognized as the code length \(n_{0}\). Then, the optimal decision threshold mentioned above will be solved. According to the above analysis, a false alarm probability \(P_{fa}\) and a miss probability \(P_{nd}\) are shown as:  
\[P_{fa}=\sum_{i=0}^{\lfloor M_{\beta}/2\rfloor}\left( \begin{array}{c}i\\ M\end{array} \right)0.5^{M} \tag{10}\]  
\[P_{nd}=\sum_{i=\lfloor M_{\beta}/2\rfloor+1}^{M}\left( \begin{array}{c}i\\ M\end{array} \right)\left(\frac{1-(1-2p_{e})^{M_{n}}}{2}\right)^{i}\cdot\left( \frac{1+(1-2p_{e})^{M_{n}}}{2}\right)^{M-i} \tag{11}\]  
According to the minimum error probability criterion, the judgment threshold \(\beta_{1}\) is defined as:  
\[\beta_{1}=\arg\min_{\beta}\left(P_{fa}+P_{nd}\right) \tag{12}\]  
According to the central limit theorem, when \(M\) is large enough, the binomial distribution tends to be normal. Based on the symmetry of the normal distribution, the analytic value of \(\beta_{1}\) can be expressed as:  
\[\beta_{1}=\frac{-b-\sqrt{b^{2}-ac}}{a} \tag{13}\]  
In Formula (13):  
\[a=\frac{-M(1-2p_{e})}{2} \tag{14}\]  
\[b=-\frac{M\left[1-(1-2p_{e})^{M_{n}}\right](1-2p_{e})^{M_{n}}}{2} \tag{15}\]  
\[c=M\left[1-(1-2p_{e})^{\omega_{b}}\right](1-2p_{e})^{\omega_{b}}-\frac{\left[ 1-(1-2p_{e})^{2M_{n}}\right]\ln\left[1-(1-2p_{e})^{2M_{n}}\right]}{2} \tag{16}\]  
In general, the code weight of the dual code words of the system code is relatively small. In order to facilitate the calculation of \(\beta_{1}\), \(M_{n}=\left\lceil\frac{n}{2}\right\rceil\). When \(M\) is large enough, the false alarm probability is:  
\[P_{fa}=\Phi\left(\sqrt{\frac{M}{2}}(\beta-1)\right) \tag{17}\]  
In Formula (17), \(\Phi\) is the standard normal distribution. As \(t\leq-3.9\), \(\Phi(t)\approx 10^{-4}\). Probability usually refers to \(|t|\geq 3.9\) as an impossible event. Therefore, we can derive from \(\sqrt{\frac{M}{2}}(\beta-1)\leq-3.9\):  
\[\beta_{2}\leq 1-3.9\sqrt{\frac{2}{M}} \tag{18}\]  
\(\beta_{1}\) will grow as \(M_{n}\) grows up. At this time, if \(M\) diminishes, \(\beta_{1}>\beta_{2}\),which will cause a larger false alarm probability. In practical application, it is generally adopted \(M=20n\) and the optimal decision threshold is defined as:  
\[\beta^{*}=\min(\beta_{1},\beta_{2}) \tag{19}\]  
The code length recognition of linear block codes has been solved, and the starting point of code words will be identified in the following chapters.