-
Notifications
You must be signed in to change notification settings - Fork 21
Description
First, thank you for this fantastic package!
Second, when calculating KL divergence on multiple vectors using KL(), the resulting matrix is symmetric -- while the documentation correctly notes that KL divergences are non-symmetric. This appears to be an issue with the divergence calculation not being done in proper order for one of the triangulars, e.g. for a 3x3 calculation, [v1,v3] and [v3,v1] are both KL(v1||v3). Reversing the order of rows in the input matrix will result in the other set of KL divergences being appropriately calculated (but still in a symmetric matrix), so there's nothing wrong with the underlying algorithm, just how it handles matrix input.
I do not know if this is intended behavior -- I assume it might be, since KL is sensitive to order when you put in 2 input vectors and does not output KL divergences for both comparisons. It feels like if it is intended, it should be mentioned in the documentation; otherwise, the symmetric output is confusing in light of the nature of KL divergence since it feels like cell [v3,v1] should be KL(v3||v1), not KL(v1||v3).