# Continuous Adaptation with Online Meta-Learning for Non-Stationary Target Regression Tasks
## 2 Preliminaries
### Bayesian Linear Regression  
Bayesian multivariate linear regression allows a closed-form analytic computation of the predictive posterior, and it is both sample and computationally efficient. Here, we consider a regression task predicting \(y_{\tau+1}\in\mathbb{R}^{n_{y}}\) from \(x_{\tau+1}\in\mathbb{R}^{n_{x}}\). It forms the linear regression over basis functions \(\phi:\mathbb{R}^{n_{x}}\rightarrow\mathbb{R}^{n_{\phi}}\). It can be written as \(y_{\tau+1}^{T}=\phi^{T}(x_{\tau+1})K+\epsilon_{\tau+1}\), where \(K\in\mathbb{R}_{n_{\phi}\times n_{y}}\) is a coefficient matrix, \(\epsilon_{t}\) is zero mean Gaussian noise with the variance \(\Sigma_{\epsilon}\), i.e., \(\epsilon_{t}\sim\mathcal{N}(0,\Sigma_{\epsilon})\). By defining \(Y^{T}=[y_{1},\cdots,y_{\tau}]\) and \(\Phi^{T}=[\phi(x_{1}),\cdots,\phi(x_{\tau})]\), the likelihood of \(Y\) given \(\Phi,K\) and \(\Sigma_{\epsilon}\) is  
\[p(Y|\Phi,K,\Sigma_{\epsilon})\propto|\Sigma_{\epsilon}|^{-ny/2}\exp\left(- \frac{1}{2}\text{tr}((Y-\Phi K)\Sigma_{\epsilon}^{-1}(Y-\Phi K))\right), \tag{1}\]  
where \(\text{tr}(.)\) denotes the trace operation. It is natural to choose a conjugate prior of \(K\), which is the matrix normal distribution. \(p(K)=\mathcal{MN}(\overline{K}_{0},\Lambda_{0}^{-1},\Sigma_{\epsilon})\), where \(\Lambda_{0}\) is a precision matrix. Then, the posterior distribution of \(K\) becomes \(p(K|\Phi,Y)=\mathcal{MN}(\overline{K}_{\tau},\Lambda_{\tau}^{-1},\Sigma_{\varepsilon})\), and the predictive posterior distribution for \(y_{\tau+1}\) can be derived by  
\[p(y_{\tau+1}|\phi(x_{\tau+1}),\Phi,Y)=\mathcal{N}(\overline{K}_{\tau}^{T}\phi(x _{\tau+1}),\Sigma_{\tau+1}), \tag{2}\]  
where  
\[\begin{split}\Sigma_{\tau+1}&=(1+\phi^{T}(x_{\tau+1})\Lambda_{ \tau}^{-1}\phi(x_{\tau+1}))\Sigma_{\varepsilon}\\ \Lambda_{\tau}&=\Phi^{T}\Phi+\Lambda_{0}\\ \overline{K}_{\tau}&=\Lambda_{\tau}^{-1}(\Phi^{T}Y+\Lambda_{0} \overline{K}_{0}).\end{split} \tag{3}\]  
Equation (3) can be rewritten in the following recursive form  
\[\begin{split}\Lambda_{\tau}&=\Lambda_{\tau-1}+\phi(x _{\tau})\phi(x_{\tau})^{T}\\ Q_{\tau}&=Q_{\tau-1}+\phi(x_{\tau})y_{\tau}^{T}\\ \overline{K}_{\tau}&=\Lambda_{\tau}^{-1}Q_{\tau}\\ \Sigma_{\tau+1}&=(1+\phi^{T}(x_{\tau+1})\Lambda_{\tau}^{-1} \phi(x_{\tau+1}))\Sigma_{\varepsilon},\end{split} \tag{4}\]  
where \(Q_{0}\) is initialised as \(\Lambda_{0}\overline{K}_{0}\), and \(\Lambda_{0}\) is the prior's precision matrix. Because \(\Lambda_{\tau}\in\mathbb{R}^{n_{\phi}\times n_{\phi}}\) and \(n_{\phi}\) can be very large, Equation (4) is computationally expensive for obtaining the predictive posterior at every time step, as it involves computing the inverse of \(\Lambda_{\tau}\) at every time step. Instead of inverting the precision matrix, we can recursively update \(\Lambda_{t}^{-1}\) directly by applying the Woodbury matrix inversion identity [14] to the first line of Equation (4), which gives  
\[\Lambda_{\tau}^{-1}=\Lambda_{\tau-1}^{-1}-\frac{(\Lambda_{\tau-1}^{-1}\phi(x _{\tau}))(\Lambda_{\tau-1}^{-1}\phi(x_{\tau}))^{T}}{1+\phi(x_{\tau})^{T} \Lambda_{\tau-1}^{-1}\phi(x_{\tau})}. \tag{5}\]  
This still requires computing \(\Lambda_{0}^{-1}\) once at the very beginning; however, this computation can be conducted offline.