# A Bayesian Modeling Approach to Situated Design of Personalized Soundscaping Algorithms
## 2 Methods
### Factor Graphs and Message Passing-Based Inference
#### 2.3.6. Message Passing-Based Inference in the Gaussian Scale Sum Model
For example, approximating the intractable terms using a full vector Taylor expansion (also over \(s_{k}\)), as with the Algonquin node, is also feasible, although this would result in an improper variational log-message that is linear in \(s_{k}\). As can be seen in Table 2, the variational message \(\overleftarrow{\
u}(s_{k})\) does not belong to a well-known probability distribution. As the sigmoidal shape of \(\overleftarrow{\
u}(s_{k})\) prevents us from directly approximating this variational message by a common distribution, we propagate the message \(\overleftarrow{\
u}(s_{k})\) in its functional form, calculate the marginal and then approximate the marginal by a well-known distribution for \begin{table}
\begin{tabular}{c c} \hline \hline
**Factor graph for the Gaussian scale sum node** \\ \hline \hline \multicolumn{2}{c}{**Node function**} \\ \hline \hline \multicolumn{2}{c}{\(p(x\mid s_{1},\,\dots,\,s_{K})=\mathcal{N}\Bigg{(}x\mid 0,\,\sum_{k=1}^{K}\exp(s_{k}),\,0 \Bigg{)}\)} \\ \hline \multicolumn{2}{c}{**Marginals**} & \multicolumn{2}{c}{**Functional form**} \\ \hline \(q(x)\) & \(\mathcal{N}_{\mathcal{C}}\big{(}x\mid\hat{m}_{x},\,\hat{\gamma}_{x}^{-1},\,0 \big{)}\) where \(\hat{m}_{x}\in\mathbb{C}\) and \(\hat{\gamma}_{x}\in\mathbb{R}^{+}\) \\ \hline \multicolumn{2}{c}{\(q(s_{k})\)} & \(\mathcal{N}\Big{(}s_{k}\mid\hat{m}_{s_{k}},\,\hat{\gamma}_{s_{k}}^{-1}\Big{)}\) where \(\hat{m}_{s_{k}}\in\mathbb{R}\) and \(\hat{\gamma}_{s_{k}}\in\mathbb{R}^{+}\) \\ \hline \multicolumn{2}{c}{**Messages**} & \multicolumn{2}{c}{**Functional form**} \\ \hline \(\bar{\
u}(x)\) & \(\mathcal{N}_{\mathcal{C}}\Bigg{(}x\mid 0,\,\sum_{k=1}^{K}\exp(\hat{m}_{s_{k}}),\,0 \Bigg{)}\) \\ \hline \(\overleftarrow{\
u}(s_{k})\) & \(\dfrac{1}{\exp(s_{k})+\sum_{i\
eq k}\exp(\hat{m}_{s_{i}})}\exp \biggl{(}-\dfrac{(\hat{\gamma}_{x}^{-1}+|\hat{m}_{x}|^{2})}{\exp(s_{k})+\sum_ {i\
eq k}\exp(\hat{m}_{s_{i}})}\biggr{)}\) \\ \hline \multicolumn{2}{c}{**Local variational free energy**} \\ \hline \multicolumn{2}{c}{\(\ln(\pi)+\ln\biggl{(}\sum_{k=1}^{K}\exp(\hat{m}_{s_{k}})\biggr{)}+\dfrac{1}{ \sum_{k=1}^{K}\exp(\hat{m}_{s_{k}})}(\hat{\gamma}_{x}^{-1}+|\hat{m}_{x}|^{2})\)} \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Table containing (a) the Forney-style factor graph representation of the Gaussian scale sum node. (b) The likelihood function corresponding to the Gaussian scale sum node. (c) An overview of the chosen approximate posterior distributions. Here the \(\hat{\cdot}\) accept refers to the parameters of these distributions. (d) The derived variational messages for the Gaussian scale sum node. (e) The derived local variational free energy. All derivations are available at [[https://github.com/biaslab/SituatedSoundscaping](https://github.com/biaslab/SituatedSoundscaping)]([https://github.com/biaslab/SituatedSoundscaping](https://github.com/biaslab/SituatedSoundscaping)), accessed on 1 July 2021.  
tractability. Therefore we pass the functional form as a message over the graph. We then derive a functional form of the resulting marginals and approximate the marginals with a Gaussian distribution for tractability. Here the log-marginal \(\ln q(s_{k})\) is approximated by a second-order Taylor expansion at its mode as  
\[\ln q(s_{k})\approx\ln q(s_{k,0})+\frac{1}{2}\frac{\mathrm{d}^{2}\ln q(s_{k})}{ \mathrm{d}s_{k}^{2}}\Big{|}_{s_{k}=s_{k,0}}(s_{k}-s_{k,0})^{2} \tag{25}\]  
where \(s_{k,0}\) is the mode of the marginal. Because the message is expanded around its mode, the first-order derivative vanishes from the Taylor expansion. This mode can be found by solving \(\frac{\mathrm{d}\ln q(s_{k})}{\mathrm{d}s_{k}}=0\) for \(s_{k}\). In our case there is no closed-form solution for the mode and therefore we need to resort to numerical optimization for finding this maximum.