Introducing Informational Entropy

Abstract

The concept of Shannon's informational entropy is introduced through a series of exercise problems. The problem was designed by the author as a part of assignment of Brown PHYS 1530.

Published
Reading time
4 min
Level
Intermediate

Share article

Problem

The concept of entropy in a thermodynamic context is directly tied to the multiplicity (Ω\Omega) of accessible microstates. A remarkably similar idea exists in information theory, where entropy quantifies the actual information content of a bit string, setting a fundamental limit on how efficiently it can be compressed.

Typically, we deal with a system described by a probability distribution over possible outcomes. We begin with the simplest case: a binary string where the probability of encountering a 0 is p(0)=pp(0) = p and a 1 is p(1)=1−pp(1) = 1-p. (Note: Throughout this problem, all logarithms are base 2, i.e., log⁡≡log⁡2\log \equiv \log_2.)

  1. Calculate the multiplicity Ω\Omega, i.e., the total number of distinct nn-bit strings containing exactly npnp 0's and n(1−p)n(1-p) 1's.

  2. To uniquely map all Ω\Omega possible configurations into kk-bit compressed strings, we require 2k≥Ω2^k \ge \Omega. Using Stirling's approximation in the limit of large nn, show that the minimum required length is k=nH(p)k = n H(p), where the Shannon entropy H(p)H(p) is defined as

    H(p)=−plog⁡p−(1−p)log⁡(1−p) .(1)H(p) = -p\log p - (1-p) \log (1-p) \, . \tag{1}
  3. Examine the properties of the Shannon entropy H(p)H(p):

    • For what value(s) of pp does H(p)H(p) reach its minimum and maximum?

    • What symmetry does H(p)H(p) have?

    • How many "logical" bits are contained in nn "physical" bits?

    • Is it plausible to interpret H(p)H(p) as both (i) the optimal compression ratio and (ii) the average number of logical bits per physical bit?

  4. By the time this problem was written, this document contained 58,57458{,}574 0's and 48,73848{,}738 1's when converted to binary. What is the total Shannon entropy of this document (in bits)? How many bits can it be compressed into?

  5. Now generalize Eq. (1) to a system with dd discrete outcomes with probability distribution {p1,p2,…,pd}\{ p_1, p_2, \dots, p_d \} satisfying pi≥0p_i \ge 0 and ∑i=1dpi=1\sum_{i=1}^d p_i = 1. By considering the multinomial multiplicity Ω=n!/∏i=1d(npi)!\Omega = n! / \prod_{i=1}^d (n p_i)! of an nn-character string, show that the generalized Shannon entropy per character is

    H(p1,…,pd)=−∑i=1dpilog⁡pi .(2)H(p_1, \dots, p_d) = -\sum_{i=1}^d p_i \log p_i \, . \tag{2}
  6. Alternatively, we can divide a binary file into 8-bit chunks (bytes), matching standard ASCII character encoding. The table below lists the 10 most frequent characters and their counts in this document:

    ␣ 2225 n 516
    e 1099 o 500
    t 965 r 484
    i 690 s 482
    a 622 \ 396

    Assuming the entire document only consists of these 10 characters, approximate the entropy HH. Does HH exceed 1? Why is that result consistent?

Solution

  1. It is just choosing where the npnp 00's should go among nn places.

    Ω(p)=(nnp)=n!(np)!(n−np)!(3)\Omega(p) = \binom{n}{np} = \frac{n!}{(np)!(n-np)!} \tag{3}
  2. Using Stirling's approximation,

    k≥log⁡Ω=log⁡n!−log⁡(np)!−log⁡(n−np)!≈nlog⁡n−n−[nplog⁡(np)−np]−[(n−np)log⁡(n−np)−(n−np)]=−n[plog⁡p+(1−p)log⁡(1−p)]=nH(p)\begin{align*} k &\ge \log \Omega \\ &= \log n! - \log (np)! - \log (n-np)! \\ &\approx n \log n - n - [np \log (np) - np] - [(n-np) \log(n-np) - (n-np)] \\ &= -n [p \log p + (1-p) \log (1-p)] \\ &= n H(p) \end{align*}
  3. Some properties of the Shannon entropy are:

    • H(p)H(p) has a minimum value of 00 at p=0p=0 and p=1p=1; and the maximum value of 11 at p=1/2p=1/2. This is in agreement with our intuition that we have zero uncertainty about obtaining 00 (or 11) with unit probability and that we have maximum uncertainty when the probabilities for getting 00 and 11 are equal.

    • H(p)H(p) is symmetric with respect to p=1/2p=1/2; we would still have the same amount of uncertainty about the information source if we obtained 00's with probability 1−p1-p.

    • We can interpret the results as nn "physical" bits containing k=nH(p)k = nH(p) "logical" bits.

    • So it follows that H(p)H(p) can be understood in both ways.

  4. 00's appear with probability 0.54580.5458 and 11's with probability 0.45420.4542.

    H(0.5458)=0.9939H(0.5458) = 0.9939

    Effectively, 0.99390.9939 logical bits are contained in a single physical bit. It cannot be compressed efficiently.

  5. We begin with the same idea of taking logarithm to the multiplicity:

    Ω=n!∏i=1d(npi)!log⁡Ω=log⁡n!−∑i=1dlog⁡(npi)!≈nlog⁡n−n−∑i=1d[npilog⁡(npi)−npi]=−n∑i=1dpilog⁡pi\begin{align*} \Omega &= \frac{n!}{\prod_{i=1}^d (np_i)!} \\ \log \Omega &= \log n! - \sum_{i=1}^d \log (np_i)! \\ &\approx n \log n - n - \sum_{i=1}^d [ np_i \log (np_i) - np_i ] \\ &= -n\sum_{i=1}^d p_i \log p_i \end{align*}

    In the last line we define the nn-independent part as the generalized entropy (including the minus sign).

  6. If you convert the letter frequencies into probabilities and calculate with the formula obtained in the previous problem, you get 3.0793.079. This should be interpreted as `containing 3.0793.079 logical bits per physical byte (8 bits)'. Although the entropy value itself may exceed 1, this is still consistent with our intuition that the optimal compression ratio cannot exceed 1.

Comments

Loading…

When we write, it can land here.