# Cross-entropy calculation

This is a really dumb question, but here goes: is there a way to compute cross-entropy of two probability distributions? There is CrossEntropyLayer[], so Mathematica knows about cross-entropy, but no actual function, it seems, unless I am missing something obvious...

• There doesn't seem to be one, but you can always use Expectation[]... – J. M. will be back soon May 17 '17 at 18:31
• @J.M. So, for symbolic dist, Expectation[Log[PDF[...], ...]? – Igor Rivin May 17 '17 at 18:44
• Like that, yes. The bonus is that Expectation[] will automatically handle it depending on whether both distributions are discrete or continuous. – J. M. will be back soon May 17 '17 at 18:47
• Also, for the case that this can't be computed symbolically, there's NExpectation – yohbs May 17 '17 at 19:29