biaslab / ForneyLab.jl

Julia package for automatically generating Bayesian inference algorithms through message passing on Forney-style factor graphs.
MIT License
149 stars 33 forks source link

Free energy computation #220

Closed ismailsenoz closed 1 year ago

ismailsenoz commented 1 year ago

ForneyLab computes free energy wrong when there is a Poisson node with a large parameter value due to this function. We spotted it with @bvdmitri and thought of letting @ThijsvdLaar know.

bvdmitri commented 1 year ago

See also Distributions.jl https://github.com/JuliaStats/Distributions.jl/blob/master/src/univariate/discrete/poisson.jl#L68 and ReactiveMP.jl https://github.com/biaslab/ReactiveMP.jl/blob/master/src/nodes/poisson.jl#L28

ismailsenoz commented 1 year ago

There is another problem: the Poisson node calls the average energy function when the output is a point mass. However, the average energy function has the wrong logic in this case. https://github.com/biaslab/ReactiveMP.jl/blob/master/src/nodes/poisson.jl#L29 should be implemented in ForneyLab as well otherwise if Poisson is used at the likelihood with data it will return wrong free energy.

ThijsvdLaar commented 1 year ago

Thanks for the heads-up!