## 3 Proposed Sensor Fusion Framework Model Using PDR and W-Fi Localization Systems
### Wi-Fi Positioning
#### 3.2.1 Wi-Fi Trilateration Algorithm  
The model presented in our previous work [16] is used for trilateration algorithm implementation. For accurate position estimation using trilateration algorithm, the experiment area should contain at least three APs. In our experiment we use four APs and these APs are placed at four corners of the experiment area. A model for Wi-Fi localization using trilateration is shown in Figure 2.  
A free space path loss, F is used to estimate the user position from APs and is expressed as [37]:  
\[\text{F}\left[\text{dBm}\right]=20\log(f)-22.55+20\text{log}_{10}(d) \tag{1}\]  
where \(d\) is the user distance from AP in meters, \(f\) is the signal frequency expressed in megahertz. The trilateration algorithm follows the models explained in [38; 39]. The distance \(d_{i}\) between smartphone \((x_{p},y_{p})\) and the APs \(A_{i}(x_{i},y_{i})\) is expressed as:  
\[d_{i}^{2}=(x_{i}-x_{p})^{2}+(y_{i}-y_{p})^{2} \tag{2}\]  
The expanded form of the equation is;  
\[d_{i}^{2}=x_{i}^{2}+x_{p}^{2}-2x_{i}x_{p}+y_{i}^{2}+y_{p}^{2}-2y_{i}y_{p} \tag{3}\]  
The above equation can be rewritten as  
\[d_{k}^{2}=x_{k}^{2}+x_{p}^{2}-2x_{k}x_{p}+y_{k}^{2}+y_{p}^{2}-2y_{k}y_{p} \tag{4}\]  
Subtracting Equation (3) from Equation (2), then the equation can be expressed as;  
\[d_{i}^{2}-d_{k}^{2}+x_{k}^{2}+y_{k}^{2}-x_{i}^{2}-y_{i}^{2}=2(x_{k}-x_{i})x_{p }+2(y_{k}-y_{i})y_{p} \tag{5}\]With \(i=1\) and by varying index \(k=2,3,4\) we obtain Equation (6).  
\[\left[\begin{array}{cc}2(x_{2}-x_{1})&2(y_{2}-y_{1})\\ 2(x3-x_{1})&2(y_{3}-y_{1})\\ 2(x4-x_{1})&2(y_{4}-y_{1})\end{array}\right]\left[\begin{array}{c}x_{p}\\ y_{p}\end{array}\right]=\left[\begin{array}{c}d_{1}^{2}-d_{2}^{2}+x_{2}^{2}+y_ {2}^{2}-x_{1}^{2}-y_{1}^{2}\\ d_{1}^{2}-d_{3}^{2}+x_{3}^{2}+y_{3}^{2}-x_{1}^{2}-y_{1}^{2}\\ d_{1}^{2}-d_{4}^{2}+x_{4}^{2}+y_{4}^{2}-x_{1}^{2}-y_{1}^{2}\end{array}\right] \tag{6}\]  
The coordinates \((x_{p},y_{p})\) of the smartphone is obtained from the above system of equations and we express the equation in a linear form with three unknowns, \(Ax=b\) where  
\[A=\left[\begin{array}{cc}2(x_{2}-x_{1})&2(y_{2}-y_{1})\\ 2(x_{3}-x_{1})&2(y_{3}-y_{1})\\ 2(x_{4}-x_{1})&2(y_{4}-y_{1})\end{array}\right], \tag{7}\]  
\[x=\left[\begin{array}{c}x_{p}\\ y_{p}\end{array}\right] \tag{8}\]  
and  
\[b=\left[\begin{array}{c}d_{1}^{2}-d_{2}^{2}+x_{2}^{2}+y_{2}^{2}-x_{1}^{2}-y_ {1}^{2}\\ d_{1}^{2}-d_{2}^{2}+x_{3}^{2}+y_{3}^{2}-x_{1}^{2}-y_{1}^{2}\\ d_{1}^{2}-d_{4}^{2}+x_{4}^{2}+y_{4}^{2}-x_{1}^{2}-y_{1}^{2}\end{array}\right] \tag{9}\]  
The solution of the equations can be the \(\left(x_{p}^{*},y_{p}^{*}\right)\) that minimizes the \(\delta\) defined by the following:  
\[\delta=\left(Ax^{*}-b\right)^{\sf T}\left(Ax^{*}-b\right) \tag{10}\]  
\[x^{*}=\left[\begin{array}{c}x_{p}^{*}\\ y_{p}^{*}\end{array}\right] \tag{11}\]  
Figure 2: Wi-Fi localization system using trilateration.  
Applying Minimum Mean Square Error (MMSE) method in the above equation, we express user position, \(x^{*}\) in the following form.  
\[x^{*}=\left(A^{T}A\right)^{-1}A^{T}b \tag{12}\]