## 5 Validation of the Proposed CARLA+
### Learning and Integration of PGM Model  
Once the data have been cleaned, pre-processed and discretized, we learn the BN based on two stages: (i) structure learning and (ii) parameter learning. Structure learning is used to learn the network structure of the BN and to highlight the dependencies of different variables on one another. For this purpose, the HC algorithm is used, and the best-scoring network structure is selected, as shown in Figure 10. The BN structure depicted in Figure 10 shows that only two of the seven random variables, Time and Clouds, are independent, while all the rest are dependent on one or another. After learning the structure of the BN, the _Bayesian estimator_ algorithm is used for parameter learning. It learns the CPDs for different variables directly from the dataset that we created previously. Some of the parameters used to learn the structure and parameter learning are presented in Table 8. Once trained, the model is evaluated based on certain criteria and then integrated into our CARLA+ by updating the random variables and their states in the model and variable configuration files. This trained model is then used to model the dynamics of the real world in the simulated environment which allows us to design customized dynamic and more realistic scenarios. The model is used to infer the state of a certain variable given the states of others, and a _Poisson_ distribution is then used to sample actual values based on the inferred state. Due to the inherent randomness incurred by the utilization of _Poisson_ distribution, we collected 100 samples relating to each permutation of the different variable states, giving us a total of 51,200 data samples. These samples are then used to visualize and present the results of the trained model. The experimental results show the distribution of Speed, Pedestrian, and Traffic variables with respect to Time of the day in Figure 11. In Figure 11, the different states of Time are represented along the \(x\)-axis, and the \(y\)-axis corresponds to the values from the three different modalities, which are Traffic, Pedestrians, and Speed. Figure 10: Bayesian Network structure for the learning-based settings. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Learning Stage** & **Parameter** & **Value** \\ \hline \multirow{3}{*}{\
\begin{tabular}{c} **Structure** \\ **Learning** \\ \end{tabular} } & Scoring method & k2 score \\ \cline{2-3}  & Epsilon & \(1\times 10^{-6}\) \\ \cline{2-3}  & White list & Possible edges \\ \hline \multirow{3}{*}{
\begin{tabular}{c} **Parameter** \\ **Learning** \\ \end{tabular} } & Estimator & BayesianEstimator \\ \cline{2-3}  & Prior type & BDeu \\ \cline{2-3}  & Equivalent sample size & 10 \\ \cline{2-3}  & Complete samples only & FALSE \\ \hline \hline \end{tabular}
\end{table} 
Table 8: Parameters for structure and parameter learning. The graph in Figure 11 shows the distributions of values we get from the _Poisson distribution_ in each particular time state. Figures 12-14 show the distributions of traffic, speed, and pedestrians, respectively. The distribution for each variable is represented with respect to the different states of Rain, Fog, and Clouds. In Figures 12-14, the \(x\)-axis and the color correspond to the states of Rain and Clouds, respectively, while the columns represent different states of Fog. Moreover, some of the results of the simulation environment are shown in Figures 15-17. All of these distributions are localized to Brooklyn City, and the year 2019. Different cities and time intervals would result in different traffic scenarios and behaviors, and as a result, different resulting distributions. From these experimental results, we have demonstrated that CARLA+ has the potential to model the dynamics of real-world scenarios more effectively and efficiently. Instead of hand-crafted rules to model certain requirements, CARLA+ can be used to automatically handle the scenarios based on their defined CPDs, which can be either hand-crafted or trained via machine learning algorithms.