# Indoor Positioning

## Theory

MAC + RSSI(Received Signal Strength Indicator)

+ RSSI: $[0, -100]$. The larger RSSI is, the more intense a signal is.

### Idea
1. Divide the area into multiple grids
2. Build the fingerprint database: $(X, Y, [(\text{MAC}_1, \text{RSSI}_1), (\text{MAC}_2, \text{RSSI}_2, \cdots, (\text{MAC}_n, \text{RSSI}_n))])$
    + When we compute RSSIs for one position, it might fluctuate, so we need to preprocess these signals
    + Both the mobile device and server can save the library
3. Obtain the vector of $([(\text{MAC}_1, \text{RSSI}_1), (\text{MAC}_2, \text{RSSI}_2, \cdots, (\text{MAC}_n, \text{RSSI}_n))])$ for user
    + Filter out improper data
    
4. Match the user vector in the fingerprint library data, and predict the user's location


### 1. WKNN (Weighted KNN)
#### Steps
1. Filter out unnecessary signals based on MAC. <!-- What is an unnecessary signal? How can we filter out them? -->
2. Find out the $k$ fingerprint points that is closet to the user by measuring RSSI. <!-- Is the distance measured by the RSSI, i.e., the larger RSSI is, the close the signal is to the user? -->
3. Get $(x, y)$ from $k$ fingerprint points and compute their weighted average as follows:
$$
(\hat{x}, \hat{y}) = \sum_{i=1}^K \frac{\frac{1}{D_i + \epsilon}}{\sum_{j=1}^K{\frac{1}{D_j + \epsilon}}}(x_i, y_i)
$$


#### Distance
$$
RSSI=\begin{bmatrix}
(x_1, y_1) & rssi_{11} & rssi_{12} & \dots & rssi_{1n} \\
(x_2, y_2) & rssi_{21} & rssi_{22} & \dots & rssi_{2n} \\
\vdots & \vdots & \vdots & & \vdots \\
(x_p, y_p) & rssi_{p1} & rssi_{p2} & \dots & rssi_{pn} \\
\end{bmatrix}
$$
\begin{align}
D_m = (\sum_{j=1}^m \vert \text{rssi}_j - \text{RSSI}_{pm}  \rvert^q )^{\frac{1}{q}}, j = 1, 2, \cdots, m, 1 \leq m \leq n \label{eq:distance}\tag{1}
\end{align}

#### Weight in Averaging
The closer a signal is to the user, the weight is larger. The distance is computed as (\ref{eq:distance}) and we simply choose its reverse as its weight.
+ $\epsilon$: Avoid division by zero. Example is $0.000001$

+ $p$: Number of fingerprint points in database
+ $n$: Number of signals.
+ $m$: Number of rssi. The user collects a vector of rssi, i.e., $[\text{rssi}_1, \text{rssi}_2, \cdots, \text{rssi}_m]$. The reason that $m \leq n$ is we filter out unncessary signals in Step 1.
+ $q$: If $q$ is selected as $2$, we compute the Euclidean distance


## Signal Preprocessing
+ filter
+ cluster


### Common Approach in fingerprint filtering
#### 1. deterministic denoising
+ Channel Propagation Model Denoising
+ Median Filter: Select the median number in the window. See details and examples in [Median_filter Wiki](https://en.wikipedia.org/wiki/Median_filter)
+ Neighborhood Mean Filtering

#### 2. probabilistic denoising

152669f68928c8651536538d4367d1ac0df7d148
ipynb
Jupyter Notebook
indoor_positioning/indoor_positioning.ipynb
orris27/computer_science_notes
ceb939810fb475fba19317a754080888ccf82eac
MIT
2019-07-05T08:00:28.000Z
2019-07-05T08:00:28.000Z
indoor_positioning/indoor_positioning.ipynb
orris27/computer_science_notes
ceb939810fb475fba19317a754080888ccf82eac
MIT
indoor_positioning/indoor_positioning.ipynb
orris27/computer_science_notes
ceb939810fb475fba19317a754080888ccf82eac
MIT
2019-12-10T15:33:43.000Z
2019-12-10T15:33:43.000Z
Qwen/Qwen-72B
1. YES
2. YES