# Probabilistic Forecasting of Electricity Demand Incorporating Mobility Data
## 2 Materials and Methods
### Gaussian Process Regression for Probabilistic Forecast  
[PERSON] and [PERSON] initially presented the GPR model [48], which was later extended by [PERSON] et al. [49] and [PERSON] et al. [50]. GPR is a kernel-based nonlinear non-parametric regression technique based on [PERSON] theorem. The covariance function is crucial in defining the relation between input data and output. GPR implies each sample follows the Gaussian distribution, and every linear combination of samples follows the joint Gaussian distribution [34]. Let the training data set \(D_{tr}=\{(\text{x}_{n},\text{y}_{n})\}_{n=1}^{N}\), where \(\text{x}_{n}\) is the input of \(n\) number and \(y_{n}\) is the output, \(p\) stands for the number of selected features, i.e., \(p=5\); \(X=[\text{x}_{1},\text{x}_{2},\ldots,\text{x}_{n}]^{T}\) is the input set containing all selected features and historical demand data, and  
Figure 2: The flowchart of the GPR-KDE probability density forecasting model. \([y_{1},y_{2},\ldots,y_{n}]^{T}\) is the output set at time \(T\). Assuming the input variables \(f(X)=f(x_{i})\) follow the \(n\) vector joint Gaussian distribution, then \(f\) is thus a \(GP\). It defines a probability distribution over functions and can be described as:  
\[f(X)\,\sim GP\big{(}m(X),K\big{(}X,X^{\prime}\big{)}\big{)} \tag{1}\]  
where \(m(X)\) and \(K(X,X^{\prime})\) are the mean and covariance functions, respectively. The GPR model takes the mapping from \(X\) to \(Y\) as a \(GP\) and may relate the input with the output terms as follows:  
\[Y=f(X)+h(X)^{T}\beta+\varepsilon \tag{2}\]  
where \(Y\) is an observation, \(f(X)\) is the mapping function, \(h(X)\) is a set of basis functions that transform the original feature vector \(X\) into a new feature vector \(h(X)\) which is in \(p\times 1\) vector, \(\beta\) is a \(p\)-by-1 vector of basis function coefficients, and \(\varepsilon\,\sim N\big{(}0,\sigma_{n}^{2}\ I\big{)}\) is noise; \(\sigma_{n}^{2}\) is the standard deviation; \(I\) is an identity matrix with appropriate dimensions. Since the noise is independent, \(Y\) is also a \(GP\):  
\[Y\,\sim GP\Big{(}m(X),K\big{(}X,X^{\prime}\big{)}+\sigma_{n}^{2}\ I\Big{)} \tag{3}\]  
The prior distribution of \(Y\) can be learned from the training data using [PERSON] theory:  
\[Y^{p}\,\sim N\Big{(}0,K\big{(}X,X^{\prime}\big{)}+\sigma_{n}^{2}\ I\Big{)} \tag{4}\]  
The prior joint distribution of training set output \(Y\) and the test output \(f_{*}\) are:  
\[ \begin{bmatrix}Y\\ f_{*}\end{bmatrix} \,\sim N\bigg{(}0, \begin{bmatrix}K(X,X)+\sigma_{n}^{2}I_{n}& K(X,x_{*})\\ K(x_{*},X)&K(x_{*},x_{*})\end{bmatrix} \bigg{)} \tag{5}\]  
where \(K(X,X)=\big{(}K\big{(}x_{i},x_{j}\big{)}\big{)}\) represents the \(N\times N\) covariance matrix on inputs of the training set \(D_{tr}\); \(\big{(}K(x_{i},x_{j})\big{)}\) is the kernel function; \(K(X,x_{*})=\big{(}k(x_{t},x_{*})\big{)}\) represents the \(N\times 1\) vector of covariance between the test point \(x_{*}\) and the training inputs in \(D_{tr}\,K(x_{*},x_{*})\) is the covariance of the test points. The posterior distribution of test set prediction \(f_{*}\) can be obtained as follows:  
\[p(y|x_{*},D)\,\sim\,N\big{(}y\Big{|}h\beta+\overline{f}_{*},cov(f_{*}\ \big{)}\big{)} \tag{6}\]  
\[\overline{f}_{*}=k(x_{*},x)^{T}\big{(}k+\sigma^{2}I\big{)}^{-1}y \tag{7}\]  
\[cov(f_{*}\ )=k(x_{*},x_{*})-k(x_{*},x)^{T}\big{(}k+\sigma^{2}I\big{)}^{-1}k(x_{* },x_{*}) \tag{8}\]  
where \(\overline{\mu}=\overline{f}_{*}\) and \(\overline{\sigma}_{f_{*}}\), \({}^{2}=cov(f_{*})\). There are many different covariance kernel functions for the GPR model to select:  
1. Squared exponential kernel function: \[K(x_{i},x_{j})=\sigma_{f}^{2}\exp[-\frac{1}{2}\frac{r^{2}}{\sigma_{l}^{2}}]\] (9) where \(\sigma_{l}\) is the characteristic length scale and \(\sigma_{f}^{2}\) is the variance of time series. Both \(\sigma_{f}^{2}\) and \(\sigma_{l}\) are parameters to be optimized during the training. \(r=\sqrt{\big{(}x_{i}-x_{j}\ \big{)}^{T}\big{(}x_{i}-x_{j}\big{)}}\) is the Euclidean distance between \(x_{i}\) and \(x_{j}\). 2.