-
Notifications
You must be signed in to change notification settings - Fork 422
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
Error thrown when using kldivergence
with infinite values
#1443
Comments
It seems the KL divergence is finite and there's even a simpler form, also for the multivariate generalization: https://rpubs.com/FJRubio/DKLtn The problem is probably the same as in JuliaMath/QuadGK.jl#38. Maybe applying the suggestion and adjusting In general, keep in mind that QuadGK is just used as a fallback in the univariate case if no closed form expressions are implemented. I'm actually happy that it does not just return an incorrect result here - even though the error is a bit confusing (confused me at least when I encountered it in some other setting). Maybe QuadGK could throw a more descriptive error in this case (and the one described in the linked issue)? |
kldivergence
with infinite values
The divergence is finite in one direction -- |
Ah, you're right of course, I missed completely that you tried to evaluate in the reverse order. The other more general comments are still valid though. As the linked issue, and my personal experience, shows the error can occur due to numerical issues even if the integral is finite. Hence I think it's still safer to throw an error than to return a possibly incorrect value such as |
It makes sense why this happens (the divergence is infinite), but I think it would be a good idea to find some way to deal with cases like this and return
Inf
.The text was updated successfully, but these errors were encountered: