
Differential Entropy
Entropy for PDFs
What is entropy? Randomness? Compression lower bound?
In this post, let’s think of entropy as a scalar function of the random variable \(X\). It is also correct to say it is a scalar function of a distribution.
Let’s first look at the definition of entropy.
\[ H(X) = \mathbb E \left[ \log \dfrac{1}{p_X(X)} \right] = \sum_{x \in \mathcal X} p_X(x) \log \dfrac{1}{p_X(x)} \]
There’s nothing particularly special here. We discussed this in the previous
post. We should be able to apply this concept to all types of
distributions — not just probability mass functions (PMFs), but also probability density functions (PDFs).
Check this lecture note from Duke to find out more.
Differential entropy is defined as follows.
\[ h(X) = \mathbb E \left[ \log \dfrac{1}{f_X(X)} \right] = \int_{\mathcal X} f_X(x) \log \dfrac{1}{f_X(x)} dx \]
\(h\) of PDFs are initially derived from \(H\) by binning the continuous random variable \(X\) into \(X^\Delta\). Let’s see how it works.
Proof
First, prepare an arbitrary PDF. In this example, we are using \(\mathcal N(x;0,1)\).
We set \(\Delta\) to bin the continuous RV \(X\).

By mean value theorem (MVT), for continuous \(f\):
\[ \exists x_i \in [i\Delta, (i+1)\Delta] : f_X(x_i) \Delta = \int_{i\Delta}^{(i+1)\Delta} f_X(x) dx \]

\[ p_{X^\Delta}(x_i) \triangleq f_X(x_i) \Delta \]

\[\begin{align*} H(X^\Delta) &= \sum_i p_{X^\Delta}(x_i) \log \dfrac{1}{p_{X^\Delta}(x_i)} \\ &= \sum_i f_X(x_i) \Delta \log \dfrac{1}{f_X(x_i) \Delta} \\ &= \sum_i f_X(x_i) \Delta \log \dfrac{1}{f_X(x_i)} + \sum_i f_X(x_i) \Delta \log \dfrac{1}{\Delta} \\ &\approx \int_{\mathcal X} f_X(x) \log \dfrac{1}{f_X(x)} dx + \log \dfrac{1}{\Delta} \\[20pt] h(X) &= \lim_{\Delta \to 0} \left( H(X^\Delta) - \log \dfrac{1}{\Delta} \right) \end{align*}\]