# A Bayesian Modeling Approach to Situated Design of Personalized Soundscaping Algorithms
## 2 Methods
### Factor Graphs and Message Passing-Based Inference
#### 2.3.2 Sum-Product Message Passing  
Suppose that we would like to calculate the marginal distribution \(p(x_{4})\), which is the probability distribution of \(x_{4}\) obtained by marginalizing over the distributions of all other random variables in (17). Here we implicitly assume that all random variables are continuous and therefore marginalization is performed through integration instead of summation. If \(p(x_{1},\ x_{2},\ x_{3},\ x_{4},\ x_{5},\ x_{6})\) were not factorizable, the marginal could be calculated as  
\[p(x_{4})=\int\cdots\int p(x_{1},\ x_{2},\ x_{3},\ x_{4},\ x_{5},\ x_{6})\; \mathrm{d}x_{\backslash\mathbb{4}}\,, \tag{18}\]  
where \(x_{\backslash j}\) denotes the set of all variables \(x_{i}\)\(\forall i\) excluding \(x_{j}\). However, the conditional independencies amongst some of the variables allow for the use of the distributive property of integration in rewriting (17) as  
\[p(x_{4})=\underbrace{\iint\underbrace{\left(\int f_{a}(x_{1},\ x_{2})\; \mathrm{d}x_{1}\right)}_{\vec{\mu}(x_{2})}f_{b}(x_{2},\ x_{3},\ x_{4})\; \mathrm{d}x_{2}\;\mathrm{d}x_{3}}_{\vec{\mu}(x_{4})}\;\underbrace{\iint f_{ c}(x_{4},\ x_{5},\ x_{6})\underbrace{f_{d}(x_{5})}_{\vec{\mu}(x_{5})}\; \mathrm{d}x_{5}\;\mathrm{d}x_{6}}_{\vec{\mu}(x_{4})}\;. \tag{19}\]  
Here the global computation of (18) is executed through a set of local computations, denoted by \(\mu\), which can be interpreted as messages that nodes in the graph send to each other. These messages are visualized in Figure 7 and can be thought of as a summaries of inference in the corresponding dashed boxes. The FFG now has arbitrarily directed edges to indicate the flow of the messages. A message \(\mu(x)\) propagating on edge \(x\) is denoted by \(\vec{\mu}(x)\) or \(\overleftarrow{\mu}(x)\) when propagating in or against the direction of the edge, respectively.  
Figure 6: The Forney-style factor graph representation of the Gaussian scale sum-based generative model fully specified by (11)–(16). The GMM composite node represents the Gaussian mixture node as specified in ([37], A.2). The Gaussian scale sum composite node has been summarized in Table 2. The dashed rectangular bounding boxes here denote plates, which represent repeating parts of the graph. Edges that are intersected by the plate boundaries are implicitly connected between plates using equality nodes.  
The message \(\vec{\mu}(x_{j})\) flowing out of an arbitrary node \(f(x_{1},\ x_{2},\ldots,x_{n})\) with incoming messages \(\vec{\mu}(x_{\setminus j})\) is given by  
\[\vec{\mu}(x_{j})\propto\int f(x_{1},\ x_{2},\ldots,x_{n})\prod_{i\in\{1,\ldots n \}\setminus j}\vec{\mu}(x_{i})\ \mathrm{d}x_{\setminus j} \tag{20}\]  
which is called the sum-product update rule [38]. This update rule is the core of the sum-product message passing algorithm, which is also known as belief propagation. This algorithm concerns the distributed calculations of various marginal functions from a factorizable global function. In the previous example the FFG was acyclic and therefore a finite predetermined number of messages is required for convergence. If this graph would have included cycles, an iterative message passing schedule would be required. This is known as loopy-belief propagation and its convergence is not guaranteed [39].