# Pattern-Based Decoding for Wi-Fi Backscatter Communication of Passive Sensors
## 4 Patterns in Smoothed Wi-Fi Signal
: Under the above assumption of \(N\), applying Equation (2) to Equation (1) leads to  
\[\hat{y}[i]=\frac{h_{1}\rho\hat{x}}{N}\sum_{k=i-N/2+1}^{i+N/2}r[k]+h_{2}\hat{x}+\sigma \tag{3}\]  
where \(\hat{x}\) is the average of \(x\) samples within the window. When the window of signal samples for smoothing includes a rising edge at \(j\), \(r[k]=1\) for \(k\geq j\), and otherwise zero. Then, the last term of the above equation becomes \(\frac{h_{1}\rho\hat{x}}{N}(i+N/2-j)\), thus making \(\hat{y}[i]\) monotonically increase for \(i\). When \(N\) includes a falling edge at \(j\), the last term becomes \(\frac{h_{1}\rho\hat{x}}{N}(j-i+N/2-1)\), and now \(\hat{y}[i]\) monotonically decreases for \(i\). This observation motivates us to exploit such patterns for decoding data bits. The following proposition shows that we can identify inclining and declining signal patterns as positive and negative gradients (slopes) of a line, respectively, via simple first-order curve fitting (linear regression) whose solution is given in a closed form. **Proposition 2**. : _First-order least-mean-square curve fitting of any monotonically increasing (decreasing) function produces a line with a positive (negative) gradient._  
Figure 3: Illustration of signal-smoothing via moving average, and slope finding via first-order curve-fitting for ideal (fluctuation-free) signal samples. Proof. : The first-order least-mean-square curve-fitting problem is presented as minimizing the cost function of \(\sum_{i}(v_{i}-(a+bu_{i}))^{2}\), where \(u_{i}\) and \(v_{i}\) are input and output samples, respectively, and \(a\) and \(b\) are the coefficients of the curve (problem variables in curve fitting). By letting the cost's partial derivatives of \(a\) and \(b\) be zero and solving the resulting simultaneous equations, we obtain the optimal \(b\) as [31]  
\[b^{*}=\frac{\sum_{i}u_{i}v_{i}-m\tilde{u}\tilde{v}}{\sum_{i}(u_{i}-\tilde{u})^ {2}}=\frac{\operatorname{cov}(u,v)}{\sigma_{u}^{2}} \tag{4}\]  
where \(\tilde{u}\) and \(\tilde{v}\) are the averages of \(u\) and \(v\), respectively, for the given samples, \(\sigma_{u}^{2}\) is the variance of \(u\), \(m\) is the number of samples, and \(\operatorname{cov}()\) is the covariance. It is known that \(\operatorname{cov}(f(u),g(u))\geq 0\) holds for any two increasing functions \(f\) and \(g\), and if one is increasing and the other is decreasing, then the inequality is reversed. Therefore, if \(v\) is a monotonically increasing function of \(u\), \(\operatorname{cov}(u,v)\geq 0\) and the optimal \(b\) is positive. Conversely, if \(v\) is a monotonically decreasing function of \(u\), \(\operatorname{cov}(u,v)<0\), and the optimal \(b\) becomes negative [32; 33]. Proposition 3.: _If \(N\) is large enough to filter out signal fluctuation while \(N\leq T\), the gradient of the fitted line for moving-averaged samples with \(N\) is always positive (negative) when the window of smoothing includes a rising (falling) edge._  
Proof. : The proof is straightforward according to Propositions 1 and 2; thus, it is omitted. Figure 4 shows the groups of signal samples for a set of bit pairs that appear in the smoothed signal of Figure 2a; we chose those of bit pairs (0, 1) and (1, 0) for straightforward illustration. The horizontal line is the average amplitude of the whole Wi-Fi frame, which is the threshold of decoding configured by the total-mean method. In an ideal condition, the first half of samples are below the line and the second half are above it for bit pair (0, 1); the opposite trend is shown for bit pair (1, 0), i.e., the signal of each case crosses the horizontal line at the center. In such a case, we achieve a reliable decoding decision of the total-mean method. However, the real samples are not aligned with the expectation. Moreover, several cases show that most samples are below or above the line, thus leading to a decoding error. For example, the 12 th group has most samples below the threshold, and the 14 th group has most samples above the threshold.