An unofficial, read-only Hacker News reader. Join the beta →

The KL Divergence Is Never Negative, Except in PyTorch (opens external site)

97 points by Anon84 3 days ago | arxiv.org | 40 comments on HN

View full thread · View on Hacker News

Comment thread (1)

  1. > It is surprisingly easy to get unexpected negative values with floating point operations.

    This why one should NEVER compute variance as difference of E(x^2) - (E(x))^2. Mathematically with infinite precision it is the same as E((x-E(x))^2) but in floating point arithmetic one can easily get negative variance when subtracting two floating numbers.