shannonInformation
-
constexpr double shannonInformation(const Complex &z) noexcept
Calculates the Shannon information content [1] of a complex sequence.
Parameters
- const Complex &z
A complex number.
Returns
- double
A real number.
In information theory, the Shannon information of a discrete random variable is defined as:
\[\DeclareMathOperator\I{I}
I(X) = -\log p(x)\]
The function returns \(-\infty\) if the probability is negative or \(0\).
Example
Complex z = 0.5 + 0.5_j;
std::cout << shannonInformation(z) << "\n";
Output:
1.38629
References