-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entropy is NaN for MatrixDirichlet with 0 entries #137
Comments
@ismailsenoz @ThijsvdLaar WDYT? |
Good catch. In the entropy for the Numerically, for a parameter matrix with an entry approaching zero, the entropy appears to approach I'd say it's up to the user to choose vague priors with appropriate epsilon approximations to prevent singularities in their algorithm. |
Passing |
Good point, in that case I think it might be good to throw a |
Yes, we can throw an assertion statement that checks the parameter vector does not contain 0. Or we can add a jitter assuming that the user is trying to pass a small value and is not aware of the domain specifications for distributions. I am not a big fan of jitters, but I also understand that getting a NaN error is annoying, and avoiding that might also be beneficial. @MagnusKoudahl Which one would have been more useful in your experience? To get an assertion error or injection of tinies automatically? @ThijsvdLaar @bvdmitri I am fine either way or open to other alternatives. |
I would be in favour of throwing an error then. Adding tinies can also lead to unexpected behaviours and hiding it from the user makes it really hard to debug. With an error the user is still in control over how they want to set up their model and can decide if adding tinies is the right call |
But Dirichlet distribution is from Distributions.jl, and I think it is impossible to modify their structure. Maybe they already implement this kind of check. |
Well as far as I remember the |
@bvdmitri That's the same error I see |
In the meantime another workaround could be the functional form constraints, which would allow you to add jitter @MagnusKoudahl . See the corresponding section in the documentation: https://biaslab.github.io/ReactiveMP.jl/stable/custom/custom-functional-form/#custom-functional-form-example . |
@MagnusKoudahl do you have time to handle this? |
Related to this issue, we also allow for other nonvalid parameterisations, ex
does not throw an error. Is ensuring correct parameterisation something worth spending time on more generally? |
When calculating the entropy of a
MatrixDirichlet
with 0 entries, the result is NaN.This follows from the
entropy
function making an elementwise call toSpecialFunctions.loggamma
ondist.a
which evaluates toInf
on each 0 entry.This means that when learning parameters of an HMM for example, a marginal that evaluates to
I
will break FE calculation.The text was updated successfully, but these errors were encountered: