# Cognitive Artificial Intelligence Using Bayesian Computing Based on Hybrid Monte Carlo Algorithm
## 3 Proposed Method
accepts the proposals at a much higher rate than the Metropolis-Hastings algorithm. In the HMC algorithm, the horizontal and vertical locations are represented by \(\theta\) and \(q\), where \(\theta\) is the parameter estimated by the HMC chain and \(q\) is a parameter for the momentum of the HMC procedure. Moreover, \(\theta\) follows the posterior distribution \(f(\theta)\) and \(q\) is used to simulate \(\theta\) in the following formula called the Hamiltonian equation [16; 17]. \[H(\theta,q)=P(\theta)+K(q) \tag{2}\]  
where the Hamiltonian function \(H(\theta,q)\) consists of energy functions \(P(\theta)\) and \(K(q)\) for potential and kinetic energies. As with other MCMC methods, we sampled \(\theta\) from \(f(\theta)\). The \(P(\theta)\) represents \(-logf(\theta)\) and \(q\) follows normal distribution \(N_{k}(0,\Sigma)\), where \(k\) is the vector length of \(\theta\) and \(\Sigma\) is the given variance-covariance matrix. Therefore, Equation (2) is expressed as follows [16; 44]:  
\[H(\theta,q)=-logf(\theta)+\frac{1}{2}q^{T}\Sigma^{-1}q \tag{3}\]  
By first differentiating Equation (3) with respect to time \(t\), we solve the Hamiltonian differential equations in HMC. So, we show the HMC algorithm precedure as follows. (Step 1) Initializing  
(1-1) Initial value of parameters, \(\theta^{0}\);  
(1-2) Time start, \(t=1\);  
(1-3) Initial log posterior density, \(logf(\theta^{0})\);  
(1-4) Generating momentum \(q\) from \(N(0,\Sigma)\). (Step 2) Sampling  
(2-1) Starting states for leapfrog, \(\widetilde{\theta}=\theta^{t-1}\), \(\widetilde{q}=q\);  
(2-2) Repeating leapfrog algorithm (\(L\) times);  
(2-3) Producing HMC proposal density, \(\widetilde{\theta}\) and \(\widetilde{q}\). (Step 3) Accepting or rejecting  
(3-1) Determining acceptance probability, \(\alpha\);  
(3-2) If accepting, \(\theta^{t}=\widetilde{\theta}\), \(q^{t}=-\widetilde{q}\);  
(3-3) If rejecting, \(\theta^{t}=\theta^{t-1}\), \(q^{t}=q^{t-1}\). (Step 4) Repeating Steps 2 and 3 until N samples are obtained, \(t=t+1\). In Step 3, the acceptance probability \(\alpha\) is determined by (4) [16]. \[\alpha=\min\left(1,\frac{exp\left(logf\left(\widetilde{\theta}\right)-\frac{ 1}{2}\widetilde{q}^{T}\Sigma^{-1}\widetilde{q}\right)}{exp\left(logf\left( \widetilde{\theta}^{t-1}\right)-\frac{1}{2}q^{T}\Sigma^{-1}q\right)}\right) \tag{4}\]  
In the current paper, we focused on the regression analysis for target modeling in CAI. Therefore, we consider the regression model as follows:  
\[y=\beta_{0}+\beta_{1}X_{1}+\beta_{2}X_{2}+\cdots+\beta_{p}X_{p}+e \tag{5}\]  
In (5), \(X=\left(1,X_{1},X_{2},\ldots,X_{p}\right)\) is the explanatory variable vector and \(y\) is the response variable. The first element of \(X\), \(1\) is a value corresponding to intercept \(\beta_{0}\). The \(e\) value is an error term following the Gaussian distribution with mean zero and constant variance \(\sigma_{e}^{2}\). \(\beta=\left(\beta_{0},\beta_{1},\ldots,\beta_{p}\right)\) is the parameter vector corresponding to \(X\). The likelihood function is expressed as Equation (6) [43]:  
\[f\left(y\middle|\beta,\sigma_{e}^{2}\right)=\left(\frac{1}{\sqrt{2\pi}\sigma_{ e}}\right)^{n}exp\left(-\frac{1}{2\sigma_{e}^{2}}(y-X\beta)^{T}(y-X\beta)\right) \tag{6}\]where \(n\) is the number of data elements. Subsequently, the priors of \(\beta\) and \(e\) are the following distributions of (7) and (8):  
\[\beta\sim\mathrm{N}\big{(}\mu_{\beta},\Sigma_{\beta}\big{)} \tag{7}\]  
\[\sigma_{e}^{2}\sim Inverse-gamma(a,b) \tag{8}\]  
By multiplying the priors and likelihood function, we obtain the posterior distribution as (9) [43]:  
Figure 1:0  
Using HMC based on (6)-(8), the regression parameters \(\hat{\beta}=\big{(}\hat{\beta}_{0},\hat{\beta}_{1},\dots,\hat{\beta}_{p}\big{)}\) are estimated. When the new input \(X^{new}\) is given, we predict response \(y\) using the estimated parameters and \(X^{new}\). In this case, the prediction of \(y\) is always an optimal single value.