# A Dynamic Urban Mobility Index from Clustering of Vehicle Speeds in a Tourist-Heavy City
## 2 Materials and Methods
### Mobility Index  
We find that the vehicle speed distributions from the collected GPS data are bimodal, with a substantial peak at rest (0 km/h) and a subsidiary, nonzero peak. Motivated by this, we propose the _Zone-based Speed Index (ZSI)_, a dynamic mobility index for a city. Given the partition of a city's area into a set of nonoverlapping zones \(\{zone_{1},zone_{2},\dots\}\), the ZSI is calculated based on the classification of the zones as either \"fast\" or \"slow\". Equation (1) gives the definition of the ZSI:  
\[\text{ZSI}(t)=\frac{N_{fast}(t)}{N_{slow}(t)+N_{fast}(t)}, \tag{1}\]  
Figure 2: A sample GPS trace from the randomly chosen vehicle, taken on July 17, 2023, from 8 am to 8 pm (local time). Red indicates slow speeds, while blue indicates fast speeds. where \(N_{slow/fast}(t)\) is the number of city zones classified as \"slow (fast) zones\" during time \(t\) (which may be instantaneous but in practice can be taken to be a time interval), and the denominator is the total number of zones for which speed data are available during \(t\). The latter accounts for the fact that some zones may not have probe vehicles present within them during \(t\) and thus should be excluded from the calculation of the ZSI. Classifying whether a city zone \(zone_{i}\) is slow or fast relies on two speed distributions for that zone. The monthly speed distribution is used to calculate the speed threshold (which may thereby vary with month), while the distribution for one-hour time intervals within the same month is used to calculate average speeds, which are then compared with the monthly threshold. Matching vehicle geolocations with the speeds of probe vehicles creates hourly and monthly vehicle speed distributions per zone. We then perform \(k\)-medians clustering [38], a representative-based clustering algorithm, which partitions a data set (the monthly speeds for each zone) into \(k\) clusters depending on which median the data point is the closest to. Since the monthly speed distribution is bimodal, regardless of the zone in our data, \(k=2\) corresponds to one \"slow\" and one \"fast\" speed cluster. Algorithm 1 outlines how \(k\)-medians clustering is performed for this study. First, \(k\) is set to \(k=2\), since we are clustering the monthly speed data as either _fast_ or _slow_ for each barangay in every month. Afterwards, \(k=2\) random initial representatives are chosen, serving as the centers of the initial clusters. The _distances_ of all speed data points from the selected representatives are then calculated from each of the representatives. Finally, each data point is then assigned to the nearest cluster representative. After clustering, a new cluster representative or center that leads to a lower total _distance_ from the cluster (from the center) is chosen. The process is repeated until convergence is achieved, i.e., until the cluster assignment remains unchanged in the succeeding steps. The \(k\)-medians algorithm is known to be robust in handling outliers. After clustering, the speed threshold for \(zone_{i}\) and month \(M\), \(v_{i}^{*}(M)\) is then calculated as the midpoint between the closest boundaries of the slow and fast clusters. The boundaries of the slow and fast clusters are the fastest speed data points belonging to the _slow_ cluster, and the slowest speed points belonging to the _fast_ cluster; thus, selecting the midpoint between these boundaries maximizes the separation of the two clusters. ```
Data: Database (\(D\), Number of representatives \(k\)) whileNo convergencedo  1. Select initial representative cluster centers. 2. Create clusters (\(C_{1},C_{k=2}\)) by assigning each point in \(D\) to closest representative in \(S\) using the distance function \(Dist(\cdot,\cdot)\). 3.