# Unequal Interval Dynamic Traffic Flow Prediction with Singular Point Detection
## 4 Singular Point Detection and Prediction via Wavelet Transform
### Next Singular Point Prediction via Weighted Similarity Measurement
Aiming to avoid the measurement error caused by abnormal data, there is an antirandom interference factor, \(\lambda_{k}\), to remove the max error of the \(k\)th training data, which denotes  
\[\lambda_{k}=\max\{\frac{|T_{j}-H_{k}(j)|}{(T_{j}+H_{k}(j))/2}\},j=0,1,2,\ldots,i. \tag{13}\]  
The factor \(\eta_{k}\) in Equation (10) denotes the correction factor between the observation and the \(k\)th historical data, which reflects the influence of the singular point distribution. It is represented by  
\[\eta_{k}=\frac{\gamma[T_{j}-H(i)]+(1-\gamma)c_{k}[T_{j}-T_{i-1}]}{H_{k}(i+1)}. \tag{14}\]  
The numerator in the fraction corresponds to the exponential smoothing value of the current time, which reflects the changing trend between the singular point of the observation and historical data. \(\gamma\) and \(\varepsilon_{k}\) construct the exponential smoothing function to  
Figure 2: Illustration of the weighted similarity measurement for the next singular point prediction. The dots, triangles and squares are the positions of detected singular points of observation, 1 st historical, and 2 nd historical traffic flow data, respectively. Question mark is the next singular point position that needs to be predicted. represent the difference of the singular points in the prediction model, which can make the predicted result more close to the actual situation. Algorithm 1 presents the pseudo code of the proposed singular point detection and prediction via a multiscale wavelet transform and weighted similarity measurement (SPDP-wtsm). Lines 1-15 present the process of singular point detection for real-time traffic data via an improved multiscale wavelet transform. As the preparation for the next singular point prediction, the \(N\) historical data loop the same process, which is shown as lines 16-22. Lines 23-35 present the prediction for the next singular point via a weighed similarity measurement. ```
1:/*Singular point detection*/
2:Input: Observation process \(x\) from \(0\sim t\)
3:Choose suitable wavelet function: \(\varphi(t)\)
4:Wavelet initialization: \(a\), \(m\), and \(\xi\)
5:\(\varphi(t)\leftarrow\theta_{a}^{(1)}(t)\) or \(\theta_{a}^{(2)}(t)\)
6:Do WT-function: \(R=X(t)*\varphi(t)\)
7:Determine zero crossing point: \(R=0\)
8:Output: \(SPS[obs]=\{T_{1},T_{2},\ldots,T_{i}\}\)
9:if\(\frac{\partial i}{\partial m}<\xi\)then
10:Determine multiscale value: \(a\)
11:else
12:Shrink \(a\)
13:\(m++\)
14:Go to line5 to line8
15:endif
16:/*Historical data preparation*/
17:Input \(N\) historical data: \(H_{1}(X)\) to \(H_{N}(X)\)
18:for\(k=1:1:N\)do
19:\(X\gets H_{k}(X)\)
20:Go to line8
21:Output: \(SPS[tra(k)]=\{H^{k}(1),H^{k}(2),\ldots,H^{k}(i)\}\)
22:endfor
23:/*Next singular point prediction*/
24:for\(k=1:1:N\)do
25:for\(j=1:1:i\)do
26:singular point error: \(error_{j}^{k}:\)
27:\(abs:\frac{2\{SPS[obs(j)]-SPS[tra(k)(j)]\}}{\{SPS[obs(j)]+SPS[tra(k)(j)]\}}\)
28:endfor
29:\(\lambda_{k}=\max\{error[k]\}\)
30:Determine the weight of \(k\)th historical data:
31:\(w_{k}=1/sum\{error[k]\}-\lambda_{k}\)
32:Set \(\eta_{k}\) as Equation (12)
33:Do prediction: \(\widetilde{T}_{i+1}=w_{k}[1+\eta_{k}]H_{k}(i+1)\)
34:endfor
35:Output the predicted next singular point: \(\widetilde{T}_{i+1}\)
```  
**Algorithm 1** Singular point detection and prediction via multiscale wavelet transform and weighted similarity measurement (SPDP-wtsm).