# Bee Swarm Metropolis-Hastings Sampling for Bayesian Inference in the Ginzburg-Landau Equation
## 3 The Proposed BeeSwarm-MH Algorithm
### Hybrid Sampling Framework Integrating Bee Swarm Intelligence with MH
#### 3.1.1 Bee Swarm Initialization  
The bee swarm initialization stage serves as the starting point of the BeeSwarm-MH sampling algorithm, laying the foundation for subsequent global exploration and local exploitation while also defining essential control parameters. First, given the parameter space dimension \(d\), the algorithm allocates a sample trajectory matrix \(\mathcal{S}\in\mathbb{R}^{T\times d}\) in advance to store the best sample from each iteration. Each individual \(i\) in the swarm is then randomly initialized with a parameter vector \(\theta_{i}\), and its corresponding log-posterior value is computed as \(f_{i}=\mathcal{F}(\theta_{i})\). The local step-size parameter \(\sigma_{i}\) is set to the initial value \(\sigma_{0}\).  
To enable the division of labor within the swarm, the algorithm assigns the first \(\lfloor\rho N\rfloor\) individuals as scout bees (scout) for global exploration, while the remaining individuals become worker bees (worker) responsible for local exploitation, which are marked with the role label \(\texttt{role}_{i}\). The global covariance matrix \(\Sigma\) is initialized as \(\sigma_{0}^{2}I_{d}\) to define the scale of multidimensional Gaussian perturbations, and the global scaling factor \(c\) is set to \(1.0\) as the baseline for subsequent adaptive step-size adjustment.  
In addition, the algorithm defines stage thresholds \(T_{1}=\lfloor\alpha T\rfloor\) and \(T_{2}=\lfloor\beta T\rfloor\) to control the multi-phase adjustment of perturbation intensity, implementing an annealing schedule from coarse to fine sampling. The initial mean log-posterior value of the swarm  
\[Q_{0}=\frac{1}{N}\sum_{i=1}^{N}f_{i},\]  
Figure 3: Workflow of the BeeSwarm-MH algorithm.  
serves as a baseline reference for later convergence diagnostics. The final output of this step includes the complete swarm state set  
\[\mathcal{B}=\{(\theta_{i},f_{i},\sigma_{i},\texttt{role}_{i})\}_{i=1}^{N},\]  
and the global control parameter set  
\[\mathcal{P}=\{\Sigma,c,T_{1},T_{2},Q_{0}\},\]  
which together provide the necessary input for the global exploration, local exploitation, adaptive step-size adjustment, and convergence diagnostics modules of the Beeswarm-MH algorithm. The detailed initialization procedure is given in Algorithm 1.  
```
0: Total number of iterations \(T\), swarm size \(N\), scout bee ratio \(\rho\), initial step size \(\sigma_{0}\)
0: Swarm state set \(\mathcal{B}\), global control parameter set \(\mathcal{P}\)
1: Set parameter space dimension \(d\) and allocate sample matrix \(\mathcal{S}\in\mathbb{R}^{T\times d}\)
2:for\(i=1\) to \(N\)do
3: Randomly initialize parameter \(\theta_{i}\), compute log-posterior \(f_{i}=\mathcal{F}(\theta_{i})\), set local step size \(\sigma_{i}\leftarrow\sigma_{0}\)
4:endfor
5: Assign the first \(\lfloor\rho N\rfloor\) individuals as scouts and the rest as workers, labeled \(\texttt{role}_{i}\in\{\texttt{scout},\texttt{worker}\}\)
6: Initialize covariance matrix \(\Sigma\leftarrow\sigma_{0}^{2}I_{d}\) and global scaling factor \(c\gets 1.0\)
7: Set stage thresholds \(T_{1}\leftarrow\lfloor\alpha T\rfloor\) and \(T_{2}\leftarrow\lfloor\beta T\rfloor\)
8: Compute initial mean log-posterior \(Q_{0}\leftarrow\frac{1}{N}\sum_{i=1}^{N}f_{i}\)
9: Return swarm state set \(\mathcal{B}=\{(\theta_{i},f_{i},\sigma_{i},\texttt{role}_{i})\}_{i=1}^{N}\) and control parameter set \(\mathcal{P}=\{\Sigma,c,T_{1},T_{2},Q_{0}\}\)
```  
**Algorithm 1** Bee Swarm Initialization  
Bee swarm initialization establishes the structural and parameter foundations necessary for subsequent stages of the algorithm. Once initialization is complete, the algorithm proceeds to the critical search phase in which scout bees perform global exploration while worker bees focus on local exploitation. The next section details the global exploration strategy of the scout bees, which perform broad searches across the parameter space to help identify promising regions.