# Lateral Oscillation Characteristics of Vehicle Trajectories on the Straight Sections of Freeways
## 3 Materials and Methods
### Data Reduction and Processing  
Preliminary screening and post-processing of valid data were necessary due to the highD dataset's colossal bulk and the fact that some of the data did not fit the scope of this study. For this purpose, we established the following principles to simplify data. (1) Remove any vehicle data that remains in the frame at the start and end of the video. These vehicles have incomplete traveling trajectories because of the lack of a comprehensive record of the car. (2) Exclude trajectory data that have a travel distance of less than 390 m. This portion of the data is removed since the road that the recordings cover is 400-420 m long, and some vehicles have large bodies and discontinuous trajectories. (3) Only retain the trajectory data with no lane changes (i.e., the number of lane changes is zero). Meanwhile, a few vehicles continued to the kerb or the hard shoulder, which is inconsistent with the optimum situation for this study as well. (4) Some vehicles were about to complete a lane change as they entered the screen or were about to leave the screen when they were ready to make a lane change. Although the number of lane changes for these vehicles remained zero, the influence of their trajectory was entirely due to the lane change behavior. It can be eliminated by comparing the value of the LA with the difference between the lane width and the vehicle width. The vehicle is regarded as making preparations for a lane change when the LA is higher than the difference. Figure 3: Schematic of lateral oscillation of vehicle trajectory. (5) Finally, there is a partial vehicle whose lateral position maximum (or minimum) was close to the start frame (or end frame) of its recording. This meant that the collected trajectory did not comprise a completed oscillation cycle because the vehicles failed to reach a peak or valley in the lateral position in the records. After the preliminary screening process, 35,223 vehicles' driving trajectory data were retained. Then, the type of vehicle needed to be clarified. However, the highD dataset had problems classifying car types (Figure 4a), and many cars and trucks had overlapping dimensions. It could make the final results ambiguous and cause the oscillation characteristics of all vehicles to converge. In actuality, the trajectories of different vehicles range greatly, and confusing the vehicle classifications would prevent a more effective analysis for each type of vehicle. As a result, this study used clustering methods to reclassify vehicle types by taking vehicle length and width as analysis variables. After comparing various clustering methods, the k-means algorithm was ultimately selected to reduce the errors in the classification. The k-means algorithm is more convenient and efficient for processing large samples and two-dimensional variables and can effectively classify vehicle types based on vehicle dimensions. According to the preliminary classification results, the classification of vehicles by the k-means algorithm is also better in line with international standards. The iterative process of the k-means algorithm was to continuously minimize the Euclidean distance (Equation (4)) from each sample to the cluster center and update the cluster center's position according to the newly divided clusters. Then, each data point was assigned to the nearest cluster. The optimal goal of this algorithm is to minimize the sum of squared errors (SSE) within a cluster, as shown in Equation (5) [31]. The stronger the sample correlation within the cluster is also at this point.