# A Carrier Estimation Method Based on MLE and KF for Weak GNSS Signals
## 3 MLE Discriminator  
### Cost Function of MLE  
Data bits in (3) may lead to 180-degree carrier-phase reversals. Therefore, there is a phase ambiguity of \(\pi\) between different data bit periods. The method to estimate data bit reversals will be discussed in Section 4.2 and is not considered in this section. Therefore, there are three unknown parameters \(A_{i}f\) and \(\varphi\) in (3). To estimate them by MLE, the cost function must be derived first. Figure 1: Block diagram of the conventional carrier tracking loop. NCO: numerically-controlled oscillator; IF: intermediate frequency. Under the assumption of white Gaussian noise, the joint probability density function of \(N\) consecutive integration results can be expressed as (4) [13]. \[p(V_{N}|A,f,\varphi)=\frac{1}{{(2\pi\sigma^{2})}^{N}}\exp\biggl{(}-\frac{1}{{2 \sigma^{2}}}\bigl{(}V_{N}-\hat{V}_{N}\bigr{)}W\bigl{(}V_{N}-\hat{V}_{N}\bigr{)} ^{H}\biggr{)} \tag{4}\]  
where \(V_{N}=[r[0],r[1],...,r[N-1]]\) represents \(N\) coherent integration results, \(\hat{V}_{N}\) is the estimate of \(V_{N}\) in the absence of noise, \(W\) is a diagonal matrix and denotes the weighting factor of \(r[n]\), (*)\({}^{H}\) denotes the transpose and conjugate operation. The estimates of the signal parameters \(A,f\) and \(\varphi\) are obtained by maximizing (4) which can achieve a minimum variance unbiased estimate with the Cramer-Rao lower bound (CRLB) [14]. Setting all the diagonal elements of \(W\) to 1, the log-likelihood cost function for various signal parameters is:  
\[ \begin{array}{ll}\Lambda(\theta|r_{N})&=-\frac{1}{{2\sigma^{2}}}\bigl{(}V_{ N}-\hat{V}_{N}\bigr{)}\bigl{(}V_{N}-\hat{V}_{N}\bigr{)}^{H}-N\ln\bigl{(}2 \pi\sigma^{2}\bigr{)}\\ &=-\frac{1}{{2\sigma^{2}}}\bigl{|}V_{N}-\hat{V}_{N}\bigr{|}^{2}-N\ln\bigl{(}2 \pi\sigma^{2}\bigr{)}\\ &=-\frac{1}{{2\sigma^{2}}}\sum\limits_{n=0}^{N-1}\bigl{(}R(r_{n})-A\cos(\alpha )\bigr{)}^{2}-\frac{1}{{2\sigma^{2}}}\sum\limits_{n=0}^{N-1}\bigl{(}I(r_{n})- A\sin(\alpha)\bigr{)}^{2}-N\ln\bigl{(}2\pi\sigma^{2}\bigr{)}\\ &=-\frac{1}{{2\sigma^{2}}}\sum\limits_{n=0}^{N-1}\Bigl{\{}{|r_{n}|}^{2}+A^{2}- 2A\bigl{[}R(r_{n})\cdot\cos(\alpha)+I(r_{n})\cdot\sin(\alpha)\bigr{]}\Bigr{\}} -N\ln\bigl{(}2\pi\sigma^{2}\bigr{)}\end{array}  \tag{5}\]  
where \(\alpha=2\pi fnT+\varphi\), \(r_{n}=r[n]\) is used to simplify the expression, \(\theta=\bigl{[} \begin{array}{cc}A&f&\varphi\end{array} \bigr{]}^{T}\) represents the signal parameter vector, \(R(\)*\()\) and \(I(\)*\()\) denote the real and imaginary part, respectively. The MLE of the signal parameters can be obtained by maximizing the log-likelihood cost function in (5), based on the observation vector \(r_{N}\) satisfying:  
\[\frac{\partial\Lambda(\theta|r_{N})}{\partial\theta}=0 \tag{6}\]  
The partial derivative for \(A\) in (6) is easy to calculate. \[\frac{\partial\Lambda}{\partial A}=-\frac{1}{{\sigma^{2}}}\sum\limits_{n=0}^{ N-1}\bigl{\{}A-[R(r_{n})\cdot\cos(\alpha)+I(r_{n})\cdot\sin(\alpha)]\bigr{\}} \tag{7}\]  
Then, \(A\) can be estimated by setting the partial derivative (7) to zero. \[A=\frac{1}{N}\sum\limits_{n=0}^{N-1}[R(r_{n})\cdot\cos(\alpha)+I(r_{n})\cdot \sin(\alpha)] \tag{8}\]  
In (5), the term \( \begin{array}{cc}|r_{n}|&2\end{array} \) on the right-hand side can be treated as a constant (no information pertains to the signal parameters). The component \(A^{2}\) contains only the parameter \(A\). Thus, the partial derivatives of \(\Lambda\) for \(f\) and \(\varphi\) depend only on the third component in which \(A\) can be regarded as a constant coefficient. Taking no account of \(A\) and ignoring irrelevant terms, the new cost function for \(f\) and \(\varphi\) can be written as:  
\[L=\sum\limits_{n=0}^{N-1}[R(r_{n})\cdot\cos(\alpha)+I(r_{n})\cdot\sin(\alpha)] \tag{9}\]  
Therefore, the MLE is converted to a two-dimensional optimization problem to search \(f\) and \(\varphi\) which maximize \(L\). Figure 2 shows the normalized cost function in (9) with respect to the frequency and phase errors. The integration time is 1 ms and \(N\) is 20.