According to this stackexchange thread, cannot swap sums and products , you cannot interchange sums and products.

$$ \Sigma\Pi x_{i,j} \ne \Pi\Sigma x_{i,j} $$

However, I found in the book, equations 8.61-8.63 patter recognition and machine learning by Bishop, you can do this. Could someone explain why you can interchange sums and products? thank you very much.


1 Answer 1


It seems to be specific to the algorithm you are looking at. I found a slide with a concrete example: https://www.cs.auckland.ac.nz/compsci773s1t/lectures/773-GGpdfs/773GG-BeliefPropagation-handouts.pdf

Basically the idea is similar to the following example:

$$x_1y_1z_1 + x_1y_1z_2+x_1y_2z_1+x_1y_2z_2 + x_2y_1z_1 + x_2y_1z_2+x_2y_2z_1+x_2y_2z_2 = (x_1+x_2)(y_1+y_2)(z_1+z_2)$$ but with much more variables.

Notice how the product of sum requires much less computation than the sum of product and that's the point of the algorithm.

  • $\begingroup$ I have edited the question, I want to know why sums and products can be interchanged? $\endgroup$
    – Chenxi
    Aug 21, 2023 at 0:58
  • $\begingroup$ Because the expression used in this specific algorithm, when expanded out, takes the form that I wrote in my answer. Notice that in the other answer, the number of terms is different than in my example. You should go through the example in the slide, with the simple version I wrote in my answer as a reference, and try to see what's really going on. $\endgroup$
    – cr001
    Aug 21, 2023 at 0:59
  • $\begingroup$ Additonal note: The number of terms difference in the expression used in the algorithm, and the one in the other answer, is caused by the subscript of the Sum and Product. They look small in font, but their effect is big. That's why you should try to understand what's going on in the expanded expression. $\endgroup$
    – cr001
    Aug 21, 2023 at 1:08
  • $\begingroup$ x\x and Xs are different, thats the point. $\endgroup$
    – Chenxi
    Aug 21, 2023 at 1:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .