# Bee Swarm Metropolis-Hastings Sampling for Bayesian Inference in the Ginzburg-Landau Equation
## 4 Bayesian Inference for the Ginzburg-Landau Equation
### Bayesian Inference Algorithm Based on Sampling Strategies  
After obtaining the observed data \(\tilde{u}(x_{i},y_{j},0.5)\), we perform Bayesian inference on the three parameters \((\beta_{0},\beta_{1},\gamma_{0})\) of the GL equation. Below, we introduce the prior distribution, likelihood function, and posterior distribution involved in the Bayesian inference. In Bayesian inference, the prior distribution reflects prior knowledge of the parameters before observing data. For the GL equation parameters \(\beta_{0},\beta_{1}\), and \(\gamma_{0}\), we assume uniform prior distributions over the ranges \([-5,0]\), \([0.1,2]\), and \([0.1,2]\), respectively. Specifically, we use uniform (log-constant) priors whose logarithmic probability is given by  
\[\ln P(\beta_{0},\beta_{1},\gamma_{0})= \begin{cases}0,&\text{if}\,-5\leq\beta_{ 0}\leq 0,\quad 0.1\leq\beta_{1}\leq 2,\quad 0.1\leq\gamma_{0}\leq 2,\\ -\infty,&\text{otherwise}.\end{cases} \]  
The likelihood function quantifies the probability of the observed data given the model parameters, facilitating the computation of the posterior distribution. The log-likelihood is defined as  
\[\ln\mathcal{L}(\tilde{u}\mid\beta_{0},\beta_{1},\gamma_{0})=-\frac{1}{2\sigma ^{2}}\sum_{i=1}^{N}\Big{(}\tilde{u}_{i}-u_{\text{pred},i}(\beta_{0},\beta_{1}, \gamma_{0})\Big{)}^{2},\]  
where \(\tilde{u}_{i}\) denotes the perturbed observed amplitude at the \(i\)-th observation point, and \(u_{\text{pred},i}(\beta_{0},\beta_{1},\gamma_{0})\) is the model-predicted amplitude at that point. Here, \(\sigma\) is the standard deviation of the noise, and \(N\) is the total number of observations. The posterior distribution combines prior knowledge and observed data, providing a comprehensive description of the model parameters for estimation and uncertainty quantification. Its logarithm is given by the sum of the log-likelihood and the log-prior:  
\[\ln P(\beta_{0},\beta_{1},\gamma_{0}\mid\tilde{u})=\ln\mathcal{L}(\tilde{u} \mid\beta_{0},\beta_{1},\gamma_{0})+\ln P(\beta_{0},\beta_{1},\gamma_{0}).\]  
Figure 5: Initial sampling points for Bayesian inference. To compare the performance of different sampling strategies in Bayesian parameter estimation, we design a unified framework compatible with both the classical MH and the BeeSwarm-MH methods incorporating swarm intelligence. Algorithm 7 presents the pseudocode of this general sampling procedure, which flexibly switches between sampling mechanisms according to the selected strategy, performing adaptive optimization and convergence assessment at each iteration. ```
0: Number of samples \(n\), swarm size \(N\), scout bee proportion \(\rho\), initial step size \(\sigma_{0}\), observed data \((X,Y,t,\text{Amplitude}_{\text{obs}})\), sampling strategy method \(\in\) {BeeSwarmMH, ClassicMH}, prior distribution \(p(\theta)\), likelihood function \(p(\text{data }|\ \theta)\)
0: Sample sequence \(\mathcal{S}\) and final parameter estimates
1: Define the target function (log-posterior): \[\mathcal{F}(\theta)=\log p(\text{data }|\ \theta)+\log p(\theta)\]
2: Initialize swarm states and strategy parameters (see Algorithm 1)
3:for\(t=1\)to\(n\)do
4:if method == BeeSwarmMH then
5: Perform scout bee global search (Algorithm 2)
6: Perform worker bee local exploitation (Algorithm 3)
7: Adaptive step size adjustment (Algorithm 4)
8:elseif method == ClassicMH then
9: Generate candidate sample and compute MH acceptance probability based on current state
10:endif
11: Store current sample and update sample sequence \(\mathcal{S}\)
12: Perform convergence diagnosis (Algorithm 5)
13:if convergence criterion is met then
14:break {Early termination of sampling}
15:endif
16:endfor
17:Output sample sequence and parameter estimates
```  
**Algorithm 7** Bayesian Parameter Estimation Framework Based on Sampling Strategies  
After establishing the Bayesian inference framework and implementing both the BeeSwarm-MH and classical MH sampling strategies, the following section validates the performance of these algorithms through numerical experiments.