## 3 Agwan: A Generative Model for Labelled, Weighted Graphs
### Parameter Fitting  
To create realistic random graphs, we need to learn the parameters \(\pi,\Theta\) from a real-world input graph \(G\). For each \(i,j\in V\), the edge weights \(W^{ij}=\{w_{ij}\}\) follow an unknown, arbitrary probability distribution. For each set of edge weights \(W^{ij}\), we choose the scaling parameter \(s^{ij}\geq\max_{W^{ij}}\), then estimate the BMM parameters for the empirical distribution \(\
icefrac{{1}}{{s^{ij}}}\cdot W^{ij}\), which has support \((0,1]\). In this section, we describe the Bayesian estimation of BMMs within a VI framework, followed by our algorithms for Agwan parameter fitting. The beta distribtion has a conjugate prior in the exponential family. The conjugate prior density function can be written as [15,28]:  
\[f(a,b)=\frac{1}{C(\alpha_{0},\beta_{0},\
u_{0})}\left[\frac{\Gamma(a+b)}{\Gamma (a)\Gamma(b)}\right]^{\
u_{0}}e^{-\alpha_{0}(a-1)}e^{-\beta_{0}(b-1)} \tag{3}\]  
where \(\alpha_{0}\), \(\beta_{0}\), \(\
u_{0}\) are free positive parameters and \(C(\alpha_{0},\beta_{0},\
u_{0})\) is a normalisation factor such that \(\int_{0}^{\infty}\int_{0}^{\infty}f(a,b)dadb=1\). Then, we obtain the posterior distribution of \(a,b\) as (with \(N\) independent and identically distributed (i.i.d.) scalar observations \(X\) = \(\{x_{1},\ldots,x_{N}\}\))  
\[ \begin{split}& f(a,b|\textbf{X})=\frac{f(\textbf{X}|a,b)f(a,b)}{ \int_{0}^{\infty}\int_{0}^{\infty}f(\textbf{X}|a,b)f(a,b)d\textbf{a}db}\\ &=\frac{1}{C(\alpha_{N},\beta_{N},\
u_{N})}\left[\frac{\Gamma(a+b )}{\Gamma(a)\Gamma(b)}\right]^{\
u_{N}}e^{-\alpha_{N}(a-1)}e^{-\beta_{N}(b-1) }d\textbf{a}db\end{split}  \tag{4}\]  
where \(\
u_{N}=\
u_{0}+N\), \(\alpha_{N}=\alpha_{0}-\sum_{n=1}^{N}\ln x_{n}\) and \(\beta_{N}=\beta_{0}-\sum_{n=1}^{N}\ln(1-x_{n})\). To avoid infinity in the practical implementation, we assign \(\varepsilon_{1}\) to \(x_{n}\) when \(x_{n}=0\) and \(1-\varepsilon_{2}\) to \(x_{n}\) when \(x_{n}=1\), where \(\varepsilon_{1}\) and \(\varepsilon_{2}\) are slightly positive real numbers. We introduce an approximation to both the conjugate prior and the posterior distributions of the beta distribution and attempt to solve the Bayesian estimation problem via the factorised approximation method. A distribution can be used as the factorised distribution of the true posterior distribution if the optimal solution to this factorised distribution has exactly the same form as its initialisation. This requirement guarantees that the estimation works iteratively. With the non-negative property of the parameters in the beta distribution and assuming that \(a\) and \(b\) are statistically independent, we could use some well-defined distribution with support \((0,+\infty)\) to approximate the conjugate prior. One possible way is to assign the gamma distribution to \(a\) and \(b\) as:  
\[f(a;\mu,\alpha)= \frac{\alpha^{\mu}}{\Gamma(\mu)}a^{\mu-1}e^{-\alpha a};\ f(b;\
u, \beta)=\frac{\beta^{\
u}}{\Gamma(\
u)}b^{\
u-1}e^{-\beta b} \tag{5}\]  
The conjugate prior is then approximated as:  
\[f(a,b)\approx f(a)f(b) \tag{6}\]  
The same form of approximation applies to the posterior distribution as:  
\[f(a,b|\textbf{X})\approx f(a|\textbf{X})f(b|\textbf{X}) \tag{7}\]  
For each observation \(\textbf{x}_{n}\), the corresponding \(\textbf{z}_{n}=[z_{n1},\ldots,z_{nM}]^{T}\) is the indication vector defined with respect to the \(M\) components in the mixture model. One element of \(z_{n}\) will be equal to \(1\) and the rest equal to \(0\), to indicate which mixture component \(z_{n}\) belongs to.