modification of variable elimination for underflow In Daphne Kollers book on Probabilistic graphical models exercise 9.3 asks the following
Ex 9.3 Consider a modified variable elimination algorithm that is allowed to multiply all of the entries in a single factor by some arbitrary constant. (For example, it may choose to renormalize a factor to sum to 1.) If we run this algorithm on the factors resulting from a Bayesian network with evidence, which types of queries can we still obtain the right answer to, and which not?
The reason i'm interested to a solution to this problem is for implementation. I'm interested in implementing the algorithm to prevent underflow issues. I can't seem to find a lot online about dealing with this especially for the sum product algorithm i've seen some stuff for max product. In particular this exercise is highlighted in chapter 10

Does anyone have a solution to this problem?

I believe that the answer is that you can answer queries of the form $P(A|B=b)$ but not of the form $P(A,B=b)$.
To see this, suppose that $F(A,B=b)$ is the outcome of the query. If we have multiplied factors $f_1,\ldots,f_k$ by scalers $c_1,\ldots,c_k$ then we get $$F(A,B=b) = \left(\prod_{i=1}^k c_i \right) P(A,B=b).$$ Then we can obtain the factor $$F'(B) = \sum_{B} F(A,B=b) = \left(\prod_{i=1}^k c_i \right) \sum_{B} P(A,B=b) = \prod_{i=1}^k c_i P(B=b).$$ Finally we get that $$\frac{F(A,B=b)}{F'(B=b)} = P(A|B=b)$$ as required.
To calculate $P(A,B=b)$ we would have to normalise at the end, which may not be part of the algorithm but is easy enough to implement.
