crossEntropy (Continuous)

constexpr double crossEntropy(Complex (*fr)(Complex), Complex (*fi)(Complex), Complex (*gr)(Complex), Complex (*gi)(Complex), double a, double b) noexcept

Calculates the continuous cross-entropy [1] of a function.

Parameters

Complex (*fr)(Complex)

The PDF of the first real distribution.

Complex (*fi)(Complex)

The PDF of the first imaginary distribution.

Complex (*gr)(Complex)

The PDF of the second real distribution.

Complex (*gi)(Complex)

The PDF of the second imaginary distribution.

double a

A real number.

double b

A real number.

Returns

double

A real number.

In information theory, the cross entropy of two continuous probability distributions is defined as:

\[H(p, q) = -\int_{\mathcal{X}}p(x)\log q(x)dx\]

Example

auto pdfRe1 = [](Complex z) { return exp(-z * z); }; // Example real PDF 1.
auto pdfRe2 = [](Complex z) { return exp(-z * z); }; // Example real PDF 2.
auto pdfIm1 = [](Complex z) { return exp(-z * z); }; // Example im PDF 1.
auto pdfIm2 = [](Complex z) { return exp(-z * z); }; // Example im PDF 2.
std::cout << crossEntropy(pdfRe1, pdfIm1, pdfRe2, pdfIm2, -INF.real(), INF.real()) << "\n";

Output:

-1.60699e-07

References