# Detecting Urban Mobility Structure and Learning Functional Distribution with Multi-Scale Features
## 3 Method
### Model 2: Urban Functional Distribution Learning with the Correlation Matrix  
The urban mobility structure embeddings learned through contrastive learning effectively capture the mobility patterns of urban residents across different regions and periods. However, objectively evaluating these embeddings remains a challenge. Given the complex relationship between urban mobility structures and the urban functional distribution, we argued that the structure of urban activities can reflect the functional distribution of a region [32]. Therefore, by using the embedding vector of urban activity structures as input, we transformed the task of learning urban functional distribution into a problem of predicting the region's POI distribution.  
We believed that different types of POIs exhibit a synergistic relationship. For instance, regions with a high number of \"shopping\" POIs tend to also have a larger number of \"food and beverages\" POIs. Based on this insight, we proposed an enhanced urban functional distribution learning model that incorporates these collaborative relationships. The synergy between POIs is quantified by analyzing the correlation in the distribution of different POI types.  
The POI distribution prediction for regions can be defined as follows: let \(\textbf{X}\ =\ \{\textbf{x}_{1},\ldots,\textbf{x}_{N}\}\) be the urban mobility structure embedding matrix for each region, where \(\textbf{x}\in\mathbb{R}^{m}\) (with \(m\) being the embedding dimension of each region) and \(\mathcal{C}\ =\ \{c_{1},\ldots,c_{q}\}\) denote the set of POI types. The label distribution matrix is \(\textbf{Y}\ =\ \{\textbf{y}_{1},\ldots,\textbf{y}_{N}\}\), where \(\textbf{y}\ =\ \Big{\{}p_{c_{1}},\ldots,p_{c_{q}}\}\) represents the true proportion of each POI type in a region, with \(p\in[0,1]\) and \(\sum_{i=1}^{q}p_{c_{i}}\). Given the training set \(\textbf{S}\ =\ \{\textbf{X},\textbf{Y}\}\ =\ \{(\textbf{x}_{1},\textbf{y}_{1}), \ldots,(\textbf{x}_{N},\textbf{y}_{N})\}\), the goal is to model the relationship between \(X\) and \(Y\).  
Figure 3 illustrates the three key steps involved in the urban functional distribution learning model. First, the embedding matrix \(\textbf{X}\) is fed into a multilayer perceptron (MLP) to obtain the initially predicted distribution \(\widehat{y}\). Second, an affinity matrix is constructed to explicitly encode POI functional synergies, which adjusts the initial predictions through matrix multiplication. Finally, the output is passed through a SoftMax function to generate the normalized POI type distribution prediction, ensuring the sum of all probabilities equals 1. The core of this method lies in defining POI functional synergies, where cosine similarity \(cos\theta_{ij}\) is used to quantify the functional relationship between region \(i\) and region \(j\), as follows:  
\[\cos\theta_{i,j}\ =\ \frac{y_{i}\cdot y_{j}}{\|y_{i}\|\cdot\|y_{j}\|} \tag{12}\]  
The KL divergence can be used to measure the difference between two probability distributions. Therefore, we adopted the KL divergence as the loss function of the urban functional distribution learning model, as follows:  
\[D_{KL}\Big{(}\widehat{Y}\parallel Y\Big{)}\ =\ \sum_{i\ =\ 1}^{N}\widehat{Y}(i) \text{log}(\frac{\hat{Y}(i)}{Y(i)}) \tag{13}\]  
where \(N\) is the number of regions, \(\widehat{Y}\) is the predicted regional label distribution, and \(Y\) is the actual regional label distribution.