# Transit Traffic Filtration Algorithm from Cleaned Matched License Plate Data
## 3 Materials and Methods
### Transit Traffic Filtration Algorithm
ascending order we lose information about the time sequence of travel time observations. However, this ordering is acceptable in our context because we evaluate the relationship between individual vehicles within 15-min time intervals, and the order of intervals is maintained by containing information about long-period travel time trends. This step improves computational efficiency while still preserving the integrity of the analysis by focusing on broader trends within discrete time intervals. ```
1: Let \(I_{1},I_{2},\ldots,I_{k}\) be consecutive time intervals with length \(\Delta t=5\) min, such that \(I_{h}=[a_{h},a_{h}+\Delta t]\), where \(a_{1}\) is time, when considered measuring is started, \(h\in\{1,2,\ldots,k\}\)
2: Let \(D_{h}=\{t_{1},t_{2},\ldots,t_{p}\}\)
3:for\(h\gets 2\) to \(k-1\)do
4:\(T_{h}:=D_{h-1}\cup D_{h}\cup D_{h+1}=\{t_{1},t_{2},\ldots,t_{n}\}\)
5:\(x_{c}:=\text{med}(\log t_{1},\log t_{2},\ldots,\log t_{n})-\alpha\cdot\sigma (\log t_{1},\log t_{2},\ldots,\log t_{n})\)\(\triangleright\) initial threshold
6:\(T^{\prime}_{h}=\{t_{d}\in T_{h}|\log t_{d}\geq x_{c}\}\)\(\triangleright\) applying the initial threshold
7:\(m:=|T^{\prime}_{h}|\)\(\triangleright\) number of travel times left
8: Let \(T^{\prime}_{h}=\{t_{h1},t_{h2},\ldots,t_{hm}\}\), where \(t_{h1}\leq t_{h1}\leq\cdots\leq t_{hm}\)\(\triangleright\)\(T^{\prime}_{h}\) in ascending order
9:for\(j\gets 2\) to \(m\)do
10:\(rmse_{j}=RMSE(t_{h1},t_{h2},\ldots,t_{hj})\)
11:if\(j=2\)then
12:\(\Delta rmse_{j}:=0\)
13:else
14:\(\Delta rmse_{j}:=|rmse_{j}-rmse_{j-1}|\)
15:endif
16:endfor
17:\(T^{\prime\prime}_{h}:=\{t_{d}\in T^{\prime}_{h}|\Delta rmse_{d}<0.05\}\)
18:\(c_{md}:=max\{T^{\prime\prime}_{h}\}\)
19:\(D^{\prime}_{h}:=\{t_{d}\in D_{h}|t_{d}\leq c_{val}\}\)\(\triangleright\) set of valid travel times from \(D_{h}\)
20:endfor
```  
**Algorithm 1** Transit traffic filtration algorithm. The algorithm then determines the number of remaining travel times, denoted as \(m\), within the filtered subset \(T^{\prime}_{h}\) (line 7). Then, these travel times are sorted (line 8) in ascending order (Figure 0(c)), resulting in a refined subset \(T^{\prime}_{h}=\{t_{h1},t_{h2},\ldots,t_{hm}\}\). This ordered representation allows for a more structured analysis of the underlying temporal patterns within the data set. This ordering is carried out due to the subsequent construction of a linear regression model during the iterative process in the inner loop of the algorithm that starts on line 9. It can be seen in Figure 0(c) that the ordered travel time records follow a linear pattern for the values that are similar to or close to each other. Using the values in the subset \(T^{\prime}_{h}\), the algorithm systematically builds a linear regression model for all data points \(\{t_{h1},t_{h2},\ldots,t_{hj}\}\) up to the most recently added value in the latest iteration. The rationale behind using a linear regression model is that it provides a straightforward and effective way to capture the expected linear relationship between consecutive travel times under normal traffic conditions. A significant deviation from this linearity would indicate an anomaly, such as a vehicle stopping, which is exactly what the algorithm aims to detect. The addition of a value that significantly deviates from the linear pattern of previous values would reflect a travel time different from that of vehicles passing through without stopping. As a result, this introduced value would alter the underlying linear pattern, leading to an increase in the root mean square error of the linear regression model calculated in step 10 of the algorithm. RMSE is calculated based on the actual travel time values and the expected travel time values obtained from the constructed linear regression line. The objective of this iterative procedure is to detect such changes in RMSE with the addition of new values, serving as an indicator of a potential deviation in travel time behavior. During each iteration, the \(\Delta rmse_{j}\) between steps is updated on-line. The \(rmse_{2}\) is set to 0.