In information theory, Shannon's source coding theorem (or noiseless coding theorem) establishes the statistical limits to possible data compression for data whose source is an independent identically-distributed random variable, and the operational meaning of the Shannon entropy.
Named after Claude Shannon, the source coding theorem shows that, in the limit, as the length of a stream of independent and identically-distributed random variable (i.i.d.) data tends to infinity, it is impossible to compress such data such that the code rate (average number of bits per symbol) is less than the Shannon entropy of the source, without it being virtually certain that information will be lost. However it is possible to get the code rate arbitrarily close to the Shannon entropy, with negligible probability of loss.
The source coding theorem for symbol codes places an upper and a lower bound on the minimal possible expected length of codewords as a function of the entropy of the input word (which is viewed as a random variable) and of the size of the target alphabet.
Note that, for data that exhibits more dependencies (whose source is not an i.i.d. random variable), the Kolmogorov complexity, which quantifies the minimal description length of an object, is more suitable to describe the limits of data compression. Shannon entropy takes into account only frequency regularities while Kolmogorov complexity takes into account all algorithmic regularities, so in general the latter is smaller. On the other hand, if an object is generated by a random process in such a way that it has only frequency regularities, entropy is close to complexity with high probability (Shen et al. 2017).
Source coding is a mapping from (a sequence of) symbols from an information source to a sequence of alphabet symbols (usually bits) such that the source symbols can be exactly recovered from the binary bits (lossless source coding) or recovered within some distortion (lossy source coding). This is one approach to data compression.
In information theory, the source coding theorem (Shannon 1948) informally states that (MacKay 2003, pg. 81, Cover 2006, Chapter 5):
i.i.d. random variables each with entropy can be compressed into more than bits with negligible risk of information loss, as ; but conversely, if they are compressed into fewer than bits it is virtually certain that information will be lost.The
NH(X)
NH(X)+(inf.source)
Let denote two finite alphabets and let and denote the set of all finite words from those alphabets (respectively).
Suppose that is a random variable taking values in and let be a uniquely decodable code from to where . Let denote the random variable given by the length of codeword .
If is optimal in the sense that it has the minimal expected word length for, then (Shannon 1948):
H(X) | |
log2a |
\leqE[S]<
H(X) | |
log2a |
+1
Where
E
Given is an i.i.d. source, its time series is i.i.d. with entropy in the discrete-valued case and differential entropy in the continuous-valued case. The Source coding theorem states that for any, i.e. for any rate larger than the entropy of the source, there is large enough and an encoder that takes i.i.d. repetition of the source,, and maps it to binary bits such that the source symbols are recoverable from the binary bits with probability of at least .
Proof of Achievability. Fix some, and let
p(x1,\ldots,xn)=\Pr\left[X1=x1, … ,Xn=xn\right].
The typical set,, is defined as follows:
\varepsilon | |
A | |
n |
=\left\{(x1, … ,xn) : \left|-
1 | |
n |
logp(x1, … ,xn)-Hn(X)\right|<\varepsilon\right\}.
The asymptotic equipartition property (AEP) shows that for large enough, the probability that a sequence generated by the source lies in the typical set,, as defined approaches one. In particular, for sufficiently large,
P((X1,X2, … ,Xn)\in
\varepsilon) | |
A | |
n |
1-\varepsilon
The definition of typical sets implies that those sequences that lie in the typical set satisfy:
2-n(H(X)+\varepsilon)\leqp\left(x1, … ,xn\right)\leq2-n(H(X)-\varepsilon)
(X1,X2, … Xn)
\left|
\varepsilon | |
A | |
n |
\right|\leq2n(H(X)+\varepsilon)
p(x1,x2, … xn)
\left|
\varepsilon | |
A | |
n |
\right|\geq(1-\varepsilon)2n(H(X)-\varepsilon)
p(x1,x2, … xn)
Since
\left|
\varepsilon | |
A | |
n |
\right|\leq2n(H(X)+\varepsilon),n(H(X)+\varepsilon)
The encoding algorithm: the encoder checks if the input sequence lies within the typical set; if yes, it outputs the index of the input sequence within the typical set; if not, the encoder outputs an arbitrary digit number. As long as the input sequence lies within the typical set (with probability at least), the encoder does not make any error. So, the probability of error of the encoder is bounded above by .
Proof of converse: the converse is proved by showing that any set of size smaller than (in the sense of exponent) would cover a set of probability bounded away from .
For let denote the word length of each possible . Define
qi=
-si | |
a |
/C
\begin{align} H(X)&=
n | |
-\sum | |
i=1 |
pilog2pi\\ &\leq
n | |
-\sum | |
i=1 |
pilog2qi\\ &=
n | |
-\sum | |
i=1 |
pilog2
-si | |
a |
+
n | |
\sum | |
i=1 |
pilog2C\\ &=
n | |
-\sum | |
i=1 |
pilog2
-si | |
a |
+log2C\\ &\leq
n | |
-\sum | |
i=1 |
-sipilog2a\\ &=ESlog2a\\ \end{align}
where the second line follows from Gibbs' inequality and the fifth line follows from Kraft's inequality:
C=
n | |
\sum | |
i=1 |
-si | |
a |
\leq1
so .
For the second inequality we may set
si=\lceil-logapi\rceil
so that
-logapi\leqsi<-logapi+1
and so
-si | |
a |
\leqpi
and
\sum
-si | |
a |
\leq\sumpi=1
and so by Kraft's inequality there exists a prefix-free code having those word lengths. Thus the minimal satisfies
\begin{align} ES&=\sumpisi\\ &<\sumpi\left(-logapi+1\right)\\ &=\sum-pi
log2pi | |
log2a |
+1\\ &=
H(X) | |
log2a |
+1\\ \end{align}
Define typical set as:
\varepsilon | |
A | |
n |
=\left
n | |
\{x | |
1 |
: \left|-
1 | |
n |
logp\left(X1, … ,Xn\right)-\overline{Hn}(X)\right|<\varepsilon\right\}.
Then, for given, for large enough, . Now we just encode the sequences in the typical set, and usual methods in source coding show that the cardinality of this set is smaller than
n(\overline{Hn | |
2 |
(X)+\varepsilon)}