Information content

In information theory, the information content, self-information, surprisal, or Shannon information is a basic quantity derived from the probability of a particular event occurring from a random variable. It can be thought of as an alternative way of expressing probability, much like odds or log-odds, but which has particular mathematical advantages in the setting of information theory.

The Shannon information can be interpreted as quantifying the level of "surprise" of a particular outcome. As it is such a basic quantity, it also appears in several other settings, such as the length of a message needed to transmit the event given an optimal source coding of the random variable.

The Shannon information is closely related to entropy, which is the expected value of the self-information of a random variable, quantifying how surprising the random variable is "on average". This is the average amount of self-information an observer would expect to gain about a random variable when measuring it.

The information content can be expressed in various units of information, of which the most common is the "bit" (more formally called the shannon), as explained below.

The term 'perplexity' has been used in language modelling to quantify the uncertainty inherent in a set of prospective events.

Definition
Claude Shannon's definition of self-information was chosen to meet several axioms:


 * 1) An event with probability 100% is perfectly unsurprising and yields no information.
 * 2) The less probable an event is, the more surprising it is and the more information it yields.
 * 3) If two independent events are measured separately, the total amount of information is the sum of the self-informations of the individual events.

The detailed derivation is below, but it can be shown that there is a unique function of probability that meets these three axioms, up to a multiplicative scaling factor. Broadly, given a real number $$b>1$$ and an event $$x$$ with probability $$P$$, the information content is defined as follows: $$\mathrm{I}(x) := - \log_b{\left[\Pr{\left(x\right)}\right]} = -\log_b{\left(P\right)}. $$

The base b corresponds to the scaling factor above. Different choices of b correspond to different units of information: when b = 2, the unit is the shannon (symbol Sh), often called a 'bit'; when b = e, the unit is the natural unit of information (symbol nat); and when b = 10, the unit is the hartley (symbol Hart).

Formally, given a discrete random variable $$X$$ with probability mass function $$p_{X}{\left(x\right)}$$, the self-information of measuring $$X$$ as outcome $$x$$ is defined as $$\operatorname I_X(x) := - \log{\left[p_{X}{\left(x\right)}\right]} = \log{\left(\frac{1}{p_{X}{\left(x\right)}}\right)}. $$

The use of the notation $$I_X(x)$$ for self-information above is not universal. Since the notation $$I(X;Y)$$ is also often used for the related quantity of mutual information, many authors use a lowercase $$h_X(x)$$ for self-entropy instead, mirroring the use of the capital $$H(X)$$ for the entropy.

Monotonically decreasing function of probability
For a given probability space, the measurement of rarer events are intuitively more "surprising", and yield more information content, than more common values. Thus, self-information is a strictly decreasing monotonic function of the probability, or sometimes called an "antitonic" function.

While standard probabilities are represented by real numbers in the interval $$[0, 1]$$, self-informations are represented by extended real numbers in the interval $$[0, \infty]$$. In particular, we have the following, for any choice of logarithmic base:


 * If a particular event has a 100% probability of occurring, then its self-information is $$-\log(1) = 0$$: its occurrence is "perfectly non-surprising" and yields no information.
 * If a particular event has a 0% probability of occurring, then its self-information is $$-\log(0) = \infty$$: its occurrence is "infinitely surprising".

From this, we can get a few general properties:


 * Intuitively, more information is gained from observing an unexpected event—it is "surprising".
 * For example, if there is a one-in-a-million chance of Alice winning the lottery, her friend Bob will gain significantly more information from learning that she won than that she lost on a given day. (See also Lottery mathematics.)
 * This establishes an implicit relationship between the self-information of a random variable and its variance.

Relationship to log-odds
The Shannon information is closely related to the log-odds. In particular, given some event $$x$$, suppose that $$p(x)$$ is the probability of $$x$$ occurring, and that $$p(\lnot x) = 1-p(x)$$ is the probability of $$x$$ not occurring. Then we have the following definition of the log-odds: $$\text{log-odds}(x) = \log\left(\frac{p(x)}{p(\lnot x)}\right)$$

This can be expressed as a difference of two Shannon informations: $$\text{log-odds}(x) = \mathrm{I}(\lnot x) - \mathrm{I}(x)$$

In other words, the log-odds can be interpreted as the level of surprise when the event doesn't happen, minus the level of surprise when the event does happen.

Additivity of independent events
The information content of two independent events is the sum of each event's information content. This property is known as additivity in mathematics, and sigma additivity in particular in measure and probability theory. Consider two independent random variables $X,\, Y$ with probability mass functions $$p_X(x)$$ and $$p_Y(y)$$ respectively. The joint probability mass function is

$$ p_{X, Y}\!\left(x, y\right) = \Pr(X = x,\, Y = y) = p_X\!(x)\,p_Y\!(y) $$

because $X$ and $Y$  are independent. The information content of the outcome $$ (X, Y) = (x, y)$$ is$$ \begin{align} \operatorname{I}_{X,Y}(x, y) &= -\log_2\left[p_{X,Y}(x, y)\right] = -\log_2 \left[p_X\!(x)p_Y\!(y)\right] \\[5pt] &= -\log_2 \left[p_X{(x)}\right] -\log_2 \left[p_Y{(y)}\right] \\[5pt] &= \operatorname{I}_X(x) + \operatorname{I}_Y(y) \end{align} $$ See  below for an example.

The corresponding property for likelihoods is that the log-likelihood of independent events is the sum of the log-likelihoods of each event. Interpreting log-likelihood as "support" or negative surprisal (the degree to which an event supports a given model: a model is supported by an event to the extent that the event is unsurprising, given the model), this states that independent events add support: the information that the two events together provide for statistical inference is the sum of their independent information.

Relationship to entropy
The Shannon entropy of the random variable $$X $$ above is defined as $$\begin{alignat}{2} \Eta(X) &= \sum_{x} {-p_{X}{\left(x\right)} \log{p_{X}{\left(x\right)}}} \\ &= \sum_{x} {p_{X}{\left(x\right)} \operatorname{I}_X(x)} \\ &{\overset{\underset{\mathrm{def}}{}}{=}} \ \operatorname{E}{\left[\operatorname{I}_X (X)\right]}, \end{alignat} $$ by definition equal to the expected information content of measurement of $$X $$. The expectation is taken over the discrete values over its support.

Sometimes, the entropy itself is called the "self-information" of the random variable, possibly because the entropy satisfies $$\Eta(X) = \operatorname{I}(X; X)$$, where $$\operatorname{I}(X;X)$$ is the mutual information of $$X$$ with itself.

For continuous random variables the corresponding concept is differential entropy.

Fair coin toss
Consider the Bernoulli trial of tossing a fair coin $$X$$. The probabilities of the events of the coin landing as heads $$\text{H}$$ and tails $$\text{T}$$ (see fair coin and obverse and reverse) are one half each, $p_X{(\text{H})} = p_X{(\text{T})} = \tfrac{1}{2} = 0.5$. Upon measuring the variable as heads, the associated information gain is $$\operatorname{I}_X(\text{H}) = -\log_2 {p_X{(\text{H})}} = -\log_2\!{\tfrac{1}{2}} = 1,$$so the information gain of a fair coin landing as heads is 1 shannon. Likewise, the information gain of measuring tails $$T$$ is$$\operatorname{I}_X(T) = -\log_2 {p_X{(\text{T})}} = -\log_2 {\tfrac{1}{2}} = 1 \text{ Sh}.$$

Fair die roll
Suppose we have a fair six-sided die. The value of a dice roll is a discrete uniform random variable $$X \sim \mathrm{DU}[1, 6]$$ with probability mass function $$p_X(k) = \begin{cases} \frac{1}{6}, & k \in \{1, 2, 3, 4, 5, 6\} \\ 0, & \text{otherwise} \end{cases}$$The probability of rolling a 4 is $p_X(4) = \frac{1}{6}$, as for any other valid roll. The information content of rolling a 4 is thus$$\operatorname{I}_{X}(4) = -\log_2{p_X{(4)}} = -\log_2{\tfrac{1}{6}} \approx 2.585\; \text{Sh}$$of information.

Two independent, identically distributed dice
Suppose we have two independent, identically distributed random variables $X,\, Y \sim \mathrm{DU}[1, 6]$ each corresponding to an independent fair 6-sided dice roll. The joint distribution of $$X$$ and $$Y$$ is$$ \begin{align} p_{X, Y}\!\left(x, y\right) & {} = \Pr(X = x,\, Y = y) = p_X\!(x)\,p_Y\!(y) \\ & {} = \begin{cases} \displaystyle{1 \over 36}, \ &x, y \in [1, 6] \cap \mathbb{N} \\ 0 & \text{otherwise.} \end{cases} \end{align}$$

The information content of the random variate $$ (X, Y) = (2,\, 4)$$ is $$ \begin{align} \operatorname{I}_{X, Y}{(2, 4)} &= -\log_2\!{\left[p_{X,Y}{(2, 4)}\right]} = \log_2\!{36} = 2 \log_2\!{6} \\ & \approx 5.169925 \text{ Sh}, \end{align} $$ and can also be calculated by additivity of events $$ \begin{align} \operatorname{I}_{X, Y}{(2, 4)} &= -\log_2\!{\left[p_{X,Y}{(2, 4)}\right]} = -\log_2\!{\left[p_X(2)\right]} -\log_2\!{\left[p_Y(4)\right]} \\ & = 2\log_2\!{6} \\ & \approx 5.169925 \text{ Sh}. \end{align} $$

Information from frequency of rolls
If we receive information about the value of the dice without knowledge of which die had which value, we can formalize the approach with so-called counting variables $$ C_k := \delta_k(X) + \delta_k(Y) = \begin{cases} 0, & \neg\, (X = k \vee Y = k) \\ 1, & \quad X = k\, \veebar \, Y = k \\ 2, & \quad X = k\, \wedge \, Y = k \end{cases} $$ for $$ k \in \{1, 2, 3, 4, 5, 6\}$$, then $ \sum_{k=1}^{6}{C_k} = 2$ and the counts have the multinomial distribution $$ \begin{align} f(c_1,\ldots,c_6) & {} = \Pr(C_1 = c_1 \text{ and } \dots \text{ and } C_6 = c_6) \\ & {} = \begin{cases} { \displaystyle {1\over{18}}{1 \over c_1!\cdots c_k!}}, \ & \text{when } \sum_{i=1}^6 c_i=2 \\ 0 & \text{otherwise,} \end{cases} \\ & {} = \begin{cases} {1 \over 18}, \ & \text{when 2 } c_k \text{ are } 1 \\ {1 \over 36}, \ & \text{when exactly one } c_k = 2 \\ 0, \ & \text{otherwise.} \end{cases} \end{align}$$

To verify this, the 6 outcomes $(X, Y) \in \left\{(k, k)\right\}_{k = 1}^{6} = \left\{ (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6) \right\}$ correspond to the event $$C_k = 2$$ and a total probability of $1⁄6$. These are the only events that are faithfully preserved with identity of which dice rolled which outcome because the outcomes are the same. Without knowledge to distinguish the dice rolling the other numbers, the other $ \binom{6}{2} = 15$ combinations correspond to one die rolling one number and the other die rolling a different number, each having probability $1⁄18$. Indeed, $ 6 \cdot \tfrac{1}{36} + 15 \cdot \tfrac{1}{18} = 1$, as required.

Unsurprisingly, the information content of learning that both dice were rolled as the same particular number is more than the information content of learning that one dice was one number and the other was a different number. Take for examples the events $$ A_k = \{(X, Y) = (k, k)\}$$ and $$ B_{j, k} = \{c_j = 1\} \cap \{c_k = 1\}$$ for $$ j \ne k, 1 \leq j, k \leq 6$$. For example, $$ A_2 = \{X = 2 \text{ and } Y = 2\}$$ and $$ B_{3, 4} = \{(3, 4), (4, 3)\}$$.

The information contents are $$ \operatorname{I}(A_2) = -\log_2\!{\tfrac{1}{36}} = 5.169925 \text{ Sh}$$ $$ \operatorname{I}\left(B_{3, 4}\right) = - \log_2 \! \tfrac{1}{18} = 4.169925 \text{ Sh}$$

Let $ \text{Same} = \bigcup_{i = 1}^{6}{A_i}$ be the event that both dice rolled the same value and $$ \text{Diff} = \overline{\text{Same}}$$ be the event that the dice differed. Then $ \Pr(\text{Same}) = \tfrac{1}{6}$ and $ \Pr(\text{Diff}) = \tfrac{5}{6}$. The information contents of the events are $$ \operatorname{I}(\text{Same}) = -\log_2\!{\tfrac{1}{6}} = 2.5849625 \text{ Sh}$$ $$ \operatorname{I}(\text{Diff}) = -\log_2\!{\tfrac{5}{6}} = 0.2630344 \text{ Sh}.$$

Information from sum of die
The probability mass or density function (collectively probability measure) of the sum of two independent random variables is the convolution of each probability measure. In the case of independent fair 6-sided dice rolls, the random variable $$ Z = X + Y$$ has probability mass function $ p_Z(z) = p_X(x) * p_Y(y) = {6 - |z - 7| \over 36} $, where $$ *$$ represents the discrete convolution. The outcome $$ Z = 5 $$ has probability $ p_Z(5) = \frac{4}{36} = {1 \over 9} $. Therefore, the information asserted is$$ \operatorname{I}_Z(5) = -\log_2{\tfrac{1}{9}} = \log_2{9} \approx 3.169925 \text{ Sh}. $$

General discrete uniform distribution
Generalizing the example above, consider a general discrete uniform random variable (DURV) $$X \sim \mathrm{DU}[a,b]; \quad a, b \in \mathbb{Z}, \ b \ge a.$$ For convenience, define $N := b - a + 1$. The probability mass function is $$p_X(k) = \begin{cases} \frac{1}{N}, & k \in [a, b] \cap \mathbb{Z} \\ 0, & \text{otherwise}. \end{cases}$$In general, the values of the DURV need not be integers, or for the purposes of information theory even uniformly spaced; they need only be equiprobable. The information gain of any observation $$X = k$$ is$$\operatorname{I}_X(k) = -\log_2{\frac{1}{N}} = \log_2{N} \text{ Sh}.$$

Special case: constant random variable
If $$b = a$$ above, $$X$$ degenerates to a constant random variable with probability distribution deterministically given by $$X = b$$ and probability measure the Dirac measure $p_X(k) = \delta_{b}(k)$. The only value $$X$$ can take is deterministically $$b$$, so the information content of any measurement of $$X$$ is$$\operatorname{I}_X(b) = - \log_2{1} = 0.$$In general, there is no information gained from measuring a known value.

Categorical distribution
Generalizing all of the above cases, consider a categorical discrete random variable with support $\mathcal{S} = \bigl\{s_i\bigr\}_{i=1}^{N}$ and probability mass function given by

$$p_X(k) = \begin{cases} p_i, & k = s_i \in \mathcal{S} \\ 0, & \text{otherwise}. \end{cases}$$

For the purposes of information theory, the values $$s \in \mathcal{S}$$ do not have to be numbers; they can be any mutually exclusive events on a measure space of finite measure that has been normalized to a probability measure $$p$$. Without loss of generality, we can assume the categorical distribution is supported on the set $[N] = \left\{1, 2, \dots, N \right\}$ ; the mathematical structure is isomorphic in terms of probability theory and therefore information theory as well.

The information of the outcome $$X = x$$ is given

$$\operatorname{I}_X(x) = -\log_2{p_X(x)}.$$

From these examples, it is possible to calculate the information of any set of independent DRVs with known distributions by additivity.

Derivation
By definition, information is transferred from an originating entity possessing the information to a receiving entity only when the receiver had not known the information a priori. If the receiving entity had previously known the content of a message with certainty before receiving the message, the amount of information of the message received is zero. Only when the advance knowledge of the content of the message by the receiver is less than 100% certain does the message actually convey information.

For example, quoting a character (the Hippy Dippy Weatherman) of comedian George Carlin: Weather forecast for tonight: dark.

Continued dark overnight, with widely scattered light by morning. Assuming that one does not reside near the polar regions, the amount of information conveyed in that forecast is zero because it is known, in advance of receiving the forecast, that darkness always comes with the night.

Accordingly, the amount of self-information contained in a message conveying content informing an occurrence of event, $$\omega_n$$, depends only on the probability of that event.

$$\operatorname I(\omega_n) = f(\operatorname P(\omega_n)) $$ for some function $$f(\cdot)$$ to be determined below. If $$\operatorname P(\omega_n) = 1$$, then $$\operatorname I(\omega_n) = 0$$. If $$\operatorname P(\omega_n) < 1$$, then $$\operatorname I(\omega_n) > 0$$.

Further, by definition, the measure of self-information is nonnegative and additive. If a message informing of event $$C$$ is the intersection of two independent events $$A$$ and $$B$$, then the information of event $$C$$ occurring is that of the compound message of both independent events $$A$$ and $$B$$ occurring. The quantity of information of compound message $$C$$ would be expected to equal the sum of the amounts of information of the individual component messages $$A$$ and $$B$$ respectively: $$\operatorname I(C) = \operatorname I(A \cap B) = \operatorname I(A) + \operatorname I(B).$$

Because of the independence of events $$A$$ and $$B$$, the probability of event $$C$$ is $$\operatorname P(C) = \operatorname P(A \cap B) = \operatorname P(A) \cdot \operatorname P(B).$$

However, applying function $$f(\cdot)$$ results in $$\begin{align} \operatorname I(C) & = \operatorname I(A) + \operatorname I(B) \\ f(\operatorname P(C)) & = f(\operatorname P(A)) + f(\operatorname P(B)) \\ & = f\big(\operatorname P(A) \cdot \operatorname P(B)\big) \\ \end{align}$$

Thanks to work on Cauchy's functional equation, the only monotone functions $$f(\cdot)$$ having the property such that $$f(x \cdot y) = f(x) + f(y)$$ are the logarithm functions $$\log_b(x)$$. The only operational difference between logarithms of different bases is that of different scaling constants, so we may assume

$$f(x) = K \log(x)$$

where $$\log$$ is the natural logarithm. Since the probabilities of events are always between 0 and 1 and the information associated with these events must be nonnegative, that requires that $$K<0$$.

Taking into account these properties, the self-information $$\operatorname I(\omega_n)$$ associated with outcome $$\omega_n$$ with probability $$\operatorname P(\omega_n)$$ is defined as: $$\operatorname I(\omega_n) = -\log(\operatorname P(\omega_n)) = \log \left(\frac{1}{\operatorname P(\omega_n)} \right) $$

The smaller the probability of event $$\omega_n$$, the larger the quantity of self-information associated with the message that the event indeed occurred. If the above logarithm is base 2, the unit of $$ I(\omega_n)$$ is shannon. This is the most common practice. When using the natural logarithm of base $$ e$$, the unit will be the nat. For the base 10 logarithm, the unit of information is the hartley.

As a quick illustration, the information content associated with an outcome of 4 heads (or any specific outcome) in 4 consecutive tosses of a coin would be 4 shannons (probability 1/16), and the information content associated with getting a result other than the one specified would be ~0.09 shannons (probability 15/16). See above for detailed examples.