# Scenario Optimisation and Sensitivity Analysis for Safe Automated Driving Using Gaussian Processes
## 3 Gaussian Processes
### Formal Description of Gaussian Processes  
We lean on the extensive work of [PERSON] [24], who formally defined the GP model by a prior distribution  
\[f(\mathbf{x})\sim\mathcal{GP}(m(\mathbf{x}),k(\mathbf{x},\mathbf{x}^{\prime}))\,, \tag{1}\]  
where \(m(\mathbf{x})\) denotes the distribution mean and \(k(\mathbf{x},\mathbf{x}^{\prime})\) the kernel function. We used the radial basis function (RBF), also known as squared exponential kernel in this paper [24].  
Given a data set \(\mathbf{\mathcal{D}}=\{(x_{i},y_{i})|i=1,\dots,n\}\), consisting of \(n\) samples, wherein \(\mathbf{x}_{i}\) denotes the vector of input data taken from the input space \(\mathcal{X}\), and \(y_{i}=f(\mathbf{x}_{i})\) the corresponding output observations from the simulation. With the definition of a Gaussian Process from Equation (1), a joint prior distribution for observed outputs \(\mathbf{f}\) and predicted outputs \(\mathbf{f}_{*}\) is described as:  
\[\begin{bmatrix}\mathbf{f}\\ \mathbf{f}_{*}\end{bmatrix}\sim\mathcal{N}\begin{pmatrix}\mathbf{0},&\begin{bmatrix} K&K_{*}^{\mathsf{T}}\\ K_{*}&K_{**}\end{bmatrix}\end{pmatrix}, \tag{2}\]  
with an assumed mean of zero and the covariance matrices \[K =k(\mathbf{X},\mathbf{X}) \tag{3}\] \[K_{*}^{T} =k(\mathbf{X},\mathbf{X}_{*})\] \[K_{*} =k(\mathbf{X}_{*},\mathbf{X})\] \[K_{**} =k(\mathbf{X}_{*},\mathbf{X}_{*})\]  
for all observed and predicted data points. Here \(\mathbf{X}\) denotes a \(d\times n\) matrix of the training inputs \(\{\mathbf{x}_{i}\}_{i=1}^{n}\) (also known as the design matrix, c.f. Section 5.1), \(d\) stands for the dimension of input space \(\mathcal{X}\), and \(\mathbf{X}_{*}\) is the matrix of test inputs. The subscript \(*\) differentiates the predicted data from the actually observed data. Without loss of generality, the mean function is usually assumed to be zero, which does not limit the mean of the posterior to zero [24].  
The posterior distribution of \(f(\cdot)\) given \(\mathbf{y}=\{f(\mathbf{x}_{1}),\ldots,f(\mathbf{x}_{n})\}\) is a Gaussian distribution given by  
\[f(\mathbf{x})|\mathbf{y}\sim\mathcal{N}(m_{*}(\mathbf{x}),\sigma^{2}\,k_{*}(\mathbf{x},\mathbf{x} ^{\prime})) \tag{4}\]  
where  
\[m_{*}(\mathbf{x}) =t(\mathbf{x})^{T}K^{-1}\mathbf{y} \tag{5}\] \[k_{*}(\mathbf{x},\mathbf{x}^{\prime}) =k(\mathbf{x},\mathbf{x}^{\prime})-\mathbf{t}(\mathbf{x})^{T}K^{-1}\mathbf{t}(\mathbf{x}^ {\prime})\] (6) \[\mathbf{t}(\mathbf{x})^{T} =(k(\mathbf{x},\mathbf{x}_{1}),\ldots,k(\mathbf{x},\mathbf{x}_{n})), \tag{7}\]  
\(\sigma^{2}\) designates the variance of the input data, and \(k(\mathbf{x},\mathbf{x}^{\prime})\) is the kernel function which both will be introduced in Section 3.2.  
The posterior distribution of the predicted value is obtained by conditioning the joint prior distribution to  
\[f_{\mathbf{*}}|f,X,X_{*}\sim\mathcal{N}(K_{*}K^{-1}f,K_{**}-K_{*}K^{-1}K_{*}^{T})\,. \tag{8}\]  
The predicted value \(f_{\mathbf{*}}\) is given by a Gaussian distribution with mean and covariance and can be evaluated over \(\mathbf{X}_{*}\). The inherent property of the GPR of providing a predictive value along with its variance is later used in the optimisation method described in Section 5.