= Differential entropy of a uniform law
{title2=$h_e(U(a,a+L))=\ln L$}
For a <continuous uniform distribution> on an interval of length $L>0$, the <probability density> is $1/L$. Direct integration gives
$$
h_e(X)=-\int_a^{a+L}\frac1L\ln\frac1L\,dx=\ln L.
$$
Thus \b[a uniform law on an interval of length $1/2$ has differential entropy $-\ln2$], while length two gives $\ln2$. Both laws have total <probability> one. The shorter interval has larger <probability density>, making $-\ln f(X)$ negative; this is neither a negative <probability> nor a negative discrete <information entropy>.
\Image[/differential-entropy-uniform-density-and-scale.png]
{title=Uniform densities can have negative or positive differential entropy}
{description=The two stipulated <continuous uniform distributions> have density two on an interval of length $1/2$ and density $1/2$ on an interval of length two. Each rectangle has area one. The reported <differential entropy> is in <nats>, using the displayed numerical coordinates.}
Back to article page