*2.1. Channel State Information*

In an OFDM system, the signal received from a multipath channel can be described as

$$
\tau = \mathbb{C}s + n\_\prime \tag{1}
$$

where *<sup>r</sup>* <sup>=</sup> [*r*1, ··· ,*rL*] <sup>∈</sup> <sup>C</sup>*<sup>L</sup>* and *<sup>s</sup>* <sup>=</sup> [*s*1, ··· ,*sL*] <sup>∈</sup> <sup>C</sup>*<sup>L</sup>* represent the received and transmitted signal vectors, respectively, *<sup>L</sup>* is the number of subcarriers, *<sup>n</sup>* is additive noise, *<sup>C</sup>* <sup>=</sup> *diag*(*c*) <sup>∈</sup> <sup>C</sup>*L*×*<sup>L</sup>* is the channel frequency response (CFR) matrix, with *c* = [*c*1, ··· , *cL*] and *cm* denoting the channel's gain at the *m*-th subcarrier.

We call vector *c* the CSI. According to the 802.11n protocol, this vector is used to recover *s* from *r* by equalizing the channel distortion caused by multipaths. Hence, the CSI *c* is readily available in every OFDM receiver.

### *2.2. Phase Information*

The CSI value *cm*, at each subcarrier *m* = 1, ··· , *L*, is a complex number. Most CSI-based fingerprint methods choose amplitudes |*cm*| as their fingerprints. However, Sen et al. [38] proposed a linear calibration method for the (raw) phase information ∠*cm*. As we show below, the calibrated phases so obtained are more stable than amplitudes, in the sense that they incur smaller changes between consecutive measurements. We summarize this calibration method below.

We assume that raw CSI measurements *c* have certain packet-by-packet random phase shifts due to synchronization errors at the receiver. More precisely, let *θ<sup>m</sup>* = ∠*cm* denote the raw phase of the *m*-th subcarrier and *φ<sup>m</sup>* denote the ideal phase that we would have received if there were no random phase shifts. We then have

$$
\theta\_{\rm II} = \phi\_{\rm m} + \frac{2\pi}{L\Delta t} l\_{\rm m} + q\_{\prime} \tag{2}
$$

where *q* denotes the unknown center frequency shift and Δ*t* denotes the delay due to both, packet detection delay (PDD) and sampling frequency offset (SFO). By *lm*, we denote the *m*-th entry of the subcarrier index vector *l*, and, as above, *L* is the number of subcarriers. For example, in the 20 MHz bandwidth 802.11n protocol, *L* = 56 and

$$l = [-28, -27, \dots, -2, -1, 1, 2, \dots, 27, 28]^\top \dots$$

In order to compensate for the effects of random phase shifts, we use

$$
\phi\_{\rm m} = \theta\_{\rm m} - o l\_{\rm m} - q\_{\prime} \tag{3}
$$

with

$$o = \frac{\theta\_L - \theta\_1}{l\_L - l\_1},$$

$$q = \frac{1}{L} \sum\_{m=1}^{L} \theta\_m.$$

Figure 1 illustrates the effect of phase calibration. On the left, we see 100 raw measurements of the CSI at subcarrier *m* = 1, and on the right, the same CSI measurements with calibrated phases. We see how, after calibration, phases are more stable than amplitudes.

**Figure 1.** (**Left**) Complex values, in polar coordinates, corresponding to subcarrier *m* = 1 of 100 raw channel state information (CSI) measurements. (**Right**) The same values after phase calibration.

### *2.3. Phase Differences*

The calibrated phase is stable at a fixed position. However, it changes drastically from one position to another. This occurs because, theoretically, for a subcarrier at 2.4 GHz, the phase goes through an entire cycle in a wavelength distance (about 12.5 cm). This is much shorter than the distance between positions used to build the fingerprint database. To go around this, instead of using the compensated phases *φm*, *m* = 1, ··· , *L*, we use their differences *ψ<sup>m</sup>* = *φm*+<sup>1</sup> − *φ*1, *m* = 1, ··· , *L* − 1, with respect to the first component, and unwrap them so as to avoid that jumps |*ψm*+<sup>1</sup> − *ψm*|, *m* = 1, ··· , *L* − 2, are bigger than or equal to *π*. This is equivalent to consider that the frequency of the first subcarrier is zero, and the frequencies of each other subcarriers are 312.5 KHz, 625 KHz,..., 20 MHz. Then, the smallest wavelength among these subcarriers becomes (<sup>300</sup> × 106 m/s)/(<sup>20</sup> × 106 Hz) = 15 m. Figure 2, shows how phase differences change more consistently than plain phases in a sequence of three points, arranged in a straight line, 0.5 m away from each other.

We use *ym*, *m* = 1, ··· , *L* − 1, to denote the resulting unwrapped calibrated phase differences (UCPDs), and use them as fingerprints for indoor localization.

**Figure 2.** (**Left**) Compensated CSI phase at three adjacent positions. (**Right**) Phase differences at the same positions.

### **3. Problem Description**

We consider a room (R2) having *A* Wi-Fi access points (APs) with *B* antennas. At time *<sup>t</sup>* <sup>∈</sup> <sup>N</sup>, a receiver, having *<sup>D</sup>* antennas, is located at *<sup>x</sup>*(*t*) <sup>∈</sup> <sup>R</sup>2, within the room. The OFDM channel establishing the communication between each AP and each receiver's antenna, has *L*, subcarriers, whose frequencies are *fm* <sup>∈</sup> <sup>R</sup>, *<sup>m</sup>* <sup>=</sup> 1, ··· , *<sup>L</sup>*. The UCPD of the *<sup>m</sup>*-th subcarrier of the channel from AP *a* antenna *b* to receiver antenna *d* is denoted by *y* (*a*,*b*,*d*) *<sup>m</sup>* (*t*), *<sup>m</sup>* <sup>=</sup> 1, ··· , *<sup>L</sup>* <sup>−</sup> 1. Let *<sup>y</sup>*(*a*,*b*,*d*)(*t*) = # *y* (*a*,*b*,*d*) <sup>1</sup> (*t*), ··· *y* (*a*,*b*,*d*) *<sup>L</sup>*−<sup>1</sup> (*t*) \$ <sup>∈</sup> <sup>R</sup>*L*−<sup>1</sup> be the set of all UCPDs of the same channel, *<sup>y</sup>*(*a*,*b*) (*t*) = # *<sup>y</sup>*(*a*,*b*,1) (*t*), ··· , *<sup>y</sup>*(*a*,*b*,*D*) (*t*) \$ be the set of all UCPDs from AP *a* antenna *b* and *y* (*t*) = # *<sup>y</sup>*(1,1) (*t*), ··· , *<sup>y</sup>*(*A*,1) (*t*), ..., *<sup>y</sup>*(1,*B*) (*t*), ··· , *<sup>y</sup>*(*A*,*B*) (*t*) \$ be the set of all UCPDs. The fingerprint at *x*(*t*) is given by *<sup>y</sup>*(*t*) <sup>∈</sup> <sup>R</sup>*N*, with *<sup>N</sup>* = (*<sup>L</sup>* <sup>−</sup> <sup>1</sup>)*ABD*.

We assume that *x*(*t*) and *y*(*t*) are generated by the following model:

$$
\mathfrak{J}(t+1) = F\mathfrak{J}(t) + w(t), \tag{4}
$$

$$y(t) = h\left(f\sharp(t)\right) + \iota(t),\tag{5}$$

where the state *ξ*(*t*) = % *x* (*t*), *x*˙ (*t*) & contains the position and velocity of the receiver at time *t*, *<sup>F</sup>* <sup>∈</sup> <sup>R</sup>4×<sup>4</sup> is the state-transition matrix, *<sup>w</sup>*(*t*) ∼ N (0, *<sup>Q</sup>*) is the process noise, *<sup>ι</sup>*(*t*) ∼ N (0, *<sup>R</sup>*) is the measurement noise, *w*(*t*) and *ι*(*t*) are white and jointly independent, and *J* = [I, 0] , with I being the identity matrix, is a selection matrix such that *Jξ*(*t*) = *x*(*t*).

We assume that matrices *F* and *Q*, as well as the fingerprints *y*(*t*) are known. On the other hand, matrix *<sup>R</sup>* and the map **<sup>j</sup>** : <sup>R</sup><sup>2</sup> <sup>→</sup> <sup>R</sup>*<sup>N</sup>* are not known.

**Problem 1.** *Based on the above model and assumptions, our goal is to estimate, at each <sup>t</sup>* <sup>∈</sup> <sup>N</sup>*, the receiver's location x*(*t*)*.*

#### **4. Proposed Positioning Method**

The proposed method is formed by three stages. The first one is called initialization. In this stage, we estimate the fingerprint model **<sup>j</sup>** : <sup>R</sup><sup>2</sup> <sup>→</sup> <sup>R</sup>*N*. The second one (static positioning), uses the estimated model and the output Equation (5) to obtain a first estimate *x*ˇ(*t*) of the receiver's location *x*(*t*), at time *<sup>t</sup>* <sup>∈</sup> <sup>N</sup>, given the fingerprint *<sup>y</sup>*(*t*). In the third stage (dynamic positioning), the estimated location *x*ˇ(*t*) obtained in the second stage is combined with the dynamic motion model (4) to obtain the final estimation *x*ˆ(*t*) of *x*(*t*).

### *4.1. Fingerprint Modeling*

The goal of this stage is to obtain estimates of both, the map *<sup>h</sup>* : <sup>R</sup><sup>2</sup> <sup>→</sup> <sup>R</sup>*<sup>N</sup>* and the matrix *<sup>R</sup>* <sup>∈</sup> <sup>R</sup>*N*×*N*. To do so, we rely on a collection of points *pi* <sup>∈</sup> <sup>R</sup>2, *<sup>i</sup>* <sup>=</sup> 1, ··· , *<sup>I</sup>*, at each of which *<sup>K</sup>* measurements *gi*,*<sup>k</sup>* <sup>∈</sup> <sup>R</sup>*N*, *<sup>k</sup>* <sup>=</sup> 1, ··· , *<sup>K</sup>* of the fingerprint are available. The ground truth of each *pi* is known.

It follows from (5) that

$$g\_{i,k} = h\left(p\_i\right) + \iota\_{i,k\_\prime} \tag{6}$$

with *<sup>ι</sup>i*,*<sup>k</sup>* ∼ N (0, *<sup>Q</sup>*) being jointly independent. Let *<sup>g</sup>*¯*<sup>i</sup>* <sup>=</sup> <sup>1</sup> *<sup>K</sup>* <sup>∑</sup>*<sup>K</sup> <sup>k</sup>*=<sup>1</sup> *gi*,*k*. We then have

*g*¯*<sup>i</sup>* = *h* (*pi*) + *ι*¯*i*, *<sup>ι</sup>*¯*<sup>i</sup>* <sup>=</sup> <sup>1</sup> *K K* ∑ *k*=1 *<sup>ι</sup>i*,*k*. (7)

Since *<sup>ι</sup>*¯*<sup>i</sup>* ∼ N 0, <sup>1</sup> *<sup>K</sup> Q* , for large *K* we can do the following approximation

$$
\mathfrak{gl}\_i \approx h \left( p\_i \right). \tag{8}
$$

We can then obtain an estimate ˆ**j** of **j** by approxmating *h*(*p*) using a Gaussian kernel expansion of the form

$$h(p) \approx \hat{h}\left(p, a\right) = \sum\_{i=1}^{l} a\_i \exp\left(-\gamma \left\|p - p\_i\right\|^2\right),\tag{9}$$

where *α* = [*α*1, ··· , *αI*] . Following [39], we choose *γ* = <sup>1</sup> <sup>2</sup> *<sup>I</sup>*1/3. Then, using (8), we estimate *<sup>α</sup>* as follows

$$\hat{\mathfrak{a}} = \arg\min\_{\mathfrak{a}} \sum\_{i=1}^{I} \left[ \hat{h}(p\_i, \mathfrak{a}) - \bar{\mathfrak{g}}\_i \right]^2. \tag{10}$$

Finally, in order to obtain an estimate *R*ˆ of *R*, we do

$$\mathcal{R} \approx \frac{1}{I} \sum\_{i=1}^{I} \frac{1}{K-1} \sum\_{k=1}^{K} \left( g\_{i,k} - \mathfrak{g}\_i \right) \left( \mathfrak{g}\_{i,k} - \mathfrak{g}\_i \right)^{\top}. \tag{11}$$
