<p>Do you already know about <a href="http://en.wikipedia.org/wiki/Shannon_noiseless_coding_theorem">Shannon's noiseless coding theorem</a>? This theorem establistes theoretical limits on lossless compression. Some of the comments from the others seem to assume you know about this theorem, but from the question, I think it may be the answer you are looking for.</p>

CC BY-SA 3.0
2011-06-18T08:35:45.133Z
I didn't know about that theorem. I guess Wikipedia's claim is not exactly correct, as the achievable compression ratio depends on the entropy of the data to be compressed.
Auron
CC BY-SA 3.0
2011-06-18T17:17:00.933Z
I believe it's really quite hard to determine the intrinsic entropy of images -- it's much easier if the data is linear rather than 2-D.
Peter Shor 
CC BY-SA 3.0
2017-05-04T19:16:40.820Z
So, what would be the maximum compression ratio for a randomly (uniform) generated text?
skan
CC BY-SA 3.0
2011-06-17T17:29:27.353Z
2011-06-17T17:29:27.353Z
Joe Fitzsimons
<p>Compression is just an <em>opportunistic</em> way of encoding things, and when asking for "the best compression ratio that can be achievable by lossless data compression", you need to be more specific about the context of the compression: the compression ratio is the ratio between the size of the compression and the size of a "raw" encoding, but the size of the "raw" encoding depends of the hypothesis on your object (i.e. the size of its domain, or the "size of the bag from which it comes"). As a simplistic example, consider the task of encoding a positive integer $n&gt;0$: </p>

<ol>
<li><p>You might use only one bit, if $n$ is the only integer you will ever encode, and you need only to remember that you encoded it.</p></li>
<li><p>The common practical solution is to use 8 bits, if the only integers you will ever encode are all between 1 and 256 (generalize to 16, 32 and 64 bits if you want).</p></li>
<li><p>If you do not have any hypothesis about the range in which falls the integer you will have to encode, a naive solution is to use $n+1$ bits ($n$ zeros followed by a one) to encode it in unary. This might not look yet as a compression, but it has the opportunistic aspect of compression: the smaller the value of $n$, the smaller the size of its unary encoding.</p></li>
<li><p>A more serious, general purpose, encoding scheme of integers is the <em>gamma</em> code: encode the value of $\lceil\log_2 n\rceil$ in unary using  $\lceil\log_2 n\rceil+1$ bits, followed by  $n$ in binary, using $\lceil\log_2 n\rceil-1$ (you do not need the leftmost bit, which is always one, since you already know the value of $\lceil\log_2 n\rceil$). This encoding uses in total $2\lceil\log_2 n\rceil-1$ bits, and is a useful compression of $n$, often use in practice. (Note that in the litterature you will find those results noted $\lg n=\max(1,\lceil\log_2 n\rceil)$ to make notations shorter.)</p></li>
<li><p>The gamma code is not <em>optimal</em>, in the sense that there are other codes which use less space for arbitrarily many integers, and more for only a finite amount. A very good reading on the topic is "An almost optimal algorithm for unbounded searching" by Jon Louis Bentley and Andrew Chi-Chih Yao from 1976 (I like in particularly their link between the complexity of search algorithms and the size of integer encodings: I find it one of the most simple and beautiful TCS results I know). The bottom line is that $2\lceil\log_2 n\rceil-1$ bits is within a factor of two of the optimal, which most agree is enough in practice given the complexity of better solutions.</p></li>
<li><p>Yet, taking the "opportunistic" approach to its limit, there is an infinite number of compression schemes taking advantage of various hypotheses. One way to deal with this infinity of opportunistic encodings (i.e. compression scheme) is to require the encoding of the hypothesis itself, and to take into account the size of the encoding of the hypothesis in the total compression size. Formally, this corresponds to encode both the compressed data <em>and the decoder</em>, or more generally to encode a program which, when executed, outputs the uncompressed object: the smallest size of such a program is called the <em><a href="http://en.wikipedia.org/wiki/Kolmogorov_complexity">Kolmogorov's complexity</a></em> $K$. This is a very theoretical construct in the sense that, without a bound on the execution time of the program, $K$ is not computable. An easy workaround around this notion is given by <a href="http://en.wikipedia.org/wiki/Leonid_Levin">Levin</a>'s self-delimiting programs, where you consider only programs with a bounded execution time (for instance, within a constant factor of the length of the original instance, which is a lower bound on the complexity of the algorithm which needs to write each symbol).</p></li>
</ol>

<p>There is a whole community working about Kolmogorov's complexity and its variants, and another community working on loss-less compression (the example on integers that I used has equivalent on many other data types), I barely scratched the surface, and others might add precisions (Kolmogorov is really not my specialty), but I hope that this might help you clarify your question, if not necessarily give you the answer you were hoping for :)</p>

CC BY-SA 3.0
2011-06-18T11:41:09.093Z
2011-06-19T04:17:36.747Z
2011-06-19T04:17:36.747Z
J.y B.y
<p>Think of a file as a string.</p>

<p>You can never do better than the Kolmogorov complexity of a string (this is by the definition of Komogorov complexity).</p>

<p>Fix a string length. So now we're only looking at strings of length n.</p>

<p>Half of all such strings can be compressed by at most 1 bit. 1/4 of all strings can be compressed by at most 2 bits. 1/8 of all such strings can be compressed by at most 3 bits.</p>

<p>So what fraction of strings (images, files, etc.) can be compressed at the ratio of 2:1 -- very, very few. So why does compression ever work? Because almost all data that real people are actually trying to compress is highly structured -- it doesn't look like a random file. The more random looking the data, the harder to compress. They go hand in hand. Most strings look random.</p>

<p>To see this in action, generate a random file using some random process. I mean a really, really random file. Now try to compress it using your favorite compression algorithm. It will either stay the same size or get bigger, almost all of the time.</p>

<p>On the flip side, there are highly compressible strings. Take the following string:
100000..000 (1 followed by a million zeros). The description of it fits in the previous sentence, and a computer could reconstruct it from that description (or one very much like it). Yet that description is nowhere near a million digits long.</p>

<p>The fact is that strings with that property (of being highly compressible) are extremely rare among all possible strings. The secondary fact is that almost all human-generated data is super, super compressible because it is so structured.</p>

CC BY-SA 3.0
2011-06-18T15:08:35.817Z
2011-06-18T15:08:35.817Z
Steve Uurtamo
<p>(just an extension of my comment)</p>

<p>(As pointed out by Joe in his answer) Shannon - in his 1948 paper, "<a href="http://cm.bell-labs.com/cm/ms/what/shannonday/shannon1948.pdf" rel="noreferrer">A Mathematical Theory of Communication</a>"  formulated the theory of data compression and established that there is a fundamental limit to lossless data compression. This limit, called the entropy rate, is denoted by H. The exact value of H depends on the information source --- more specifically, the statistical nature of the source. It is possible to compress the source, in a lossless manner, with compression rate close to H. It is mathematically impossible to do better than H. </p>

<p>However some class of images (for example medical grayscale images) without high-contrast edges and with smooth level transitions can be compressed (not so efficiently).</p>

<p><strong>JPEG-LS</strong> and <strong>JPEG2000</strong> seem to be the standards for lossless storage of medical images. See this table for a comparison of <a href="http://www.accusoft.com/picmedxfeatures.htm" rel="noreferrer">compression ratios</a> (the JPEG-LS achieves a slightly better compression).</p>

<p>Using "lossless medical image compression" I found the following articles that may help you:</p>

<p>A recent (2011) survey on medical image compression techniques: <a href="http://www.icgst.com/gvip/Volume11/Issue1/P1151026155.pdf" rel="noreferrer">Two Dimensional Medical Image Compression Techniques - A Survey</a></p>

<p><em>... This paper presents overview of various compression techniques based
on DCT, DWT, ROI and Neural Networks for two dimensional (2D) still medical images.</em></p>

<p>A detailed presentation of two standard lossless compression algorithms: JPEG-LS and JPG2000 in lossless mode: <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34.4801&amp;rep=rep1&amp;type=pdf" rel="noreferrer">Lossless Compression of Grayscale Medical Images - Effectiveness of Traditional and State of the Art Approaches</a></p>

<p><em>... Three thousand, six hundred and seventy-nine (3,679) single frame grayscale images from multiple anatomical regions,modalities and vendors, were tested. ...</em></p>

<p>Another survey: <a href="http://kanchan-iitg.tripod.com/sitebuildercontent/sitebuilderfiles/imagecompression.pdf" rel="noreferrer">A Survey of Contemporary Medical Image Compression Techniques</a></p>

<p><strong>EDIT</strong></p>

<p>Perhaps you are still wondering "What the hell is the entropy of an image?" ... OK, it's the <em>amount of information contained in the image</em> ... but to better understand it, you should read something about the 3 phases usually used in <strong>image compression</strong>:</p>

<ul>
<li>transformation (for example Discrete Wavelet Transformation)</li>
<li>quantization</li>
<li>entropy encoding</li>
</ul>

<p>You can use Google to search for a tutorial or book on Image compression (for example <a href="http://www.debugmode.com/imagecmp/index.htm" rel="noreferrer">a quick tutorial</a>), or try to watch an online technical video (for example <a href="http://www.youtube.com/watch?v=SnstUsMJ4V4" rel="noreferrer">Lecture 16 - Introduction to Image and Video coding</a>).</p>

CC BY-SA 3.0
2011-06-18T10:13:21.557Z
2011-06-18T11:32:27.087Z
2011-06-18T11:32:27.087Z
Marzio De Biasi
<h1>Compression limit of an individual sequence</h1>
<p>What is the compression limit of a sequence?</p>
<p>Two answers can be given to this question:</p>
<ol>
<li><p><strong>The compression limit of a sequence is an unsolved problem.</strong> Furthermore, it has been shown that this limit cannot be calculated.</p>
</li>
<li><p><strong>Shannon defined a subproblem of great practical relevance, in which it is possible to define a theoretical limit (source coding theorem).</strong> This subproblem is purely probabilistic and is called source coding.</p>
</li>
</ol>
<h2>Definition of the information transfer problem in its most general form</h2>
<p>To understand these two answers it is essential to introduce the problem of information transmission in its most general form. For the transmission of information to take place between two points, it is essential that the two subjects share a communication language. This requirement is necessary, without a language of communication, the transmitted message is not understood and therefore does not carry any information. <strong>Consequently, the information transmission problem, in its most general form, studies the transfer of information in any form between two points that share a language of communication.</strong></p>
<p>The problem with this definition is that the concept of &quot;information in any form&quot; is difficult to formalize mathematically. <strong>For this reason, it is essential to introduce a first simplification of the problem, in which the information is defined as a numerical sequence.</strong> In this way, a subproblem is obtained, in which the concept of information is well-defined and can be formalized from the mathematical point of view.</p>
<p>Consequently, the two elements necessary for the transfer of information are: a compressed sequence which carries the information and a communication language known by both the encoder and the decoder.</p>
<p><strong>Compressed sequence:</strong> represents any information derived from the sequence to be transmitted. From a practical point of view, any information obtained from the sequence that is useful for the decoder to go back to the original message must be considered part of the compressed message.</p>
<p><strong>Communication language:</strong> represents a set of rules that allows communication and therefore the transfer of information between two subjects. From a practical point of view, any information present before the generation of the message can be considered part of the communication language.</p>
<h2>Source coding</h2>
<p><strong>Shannon in his famous article “A Mathematical Theory of Communication” introduces a further modification to the information transfer problem, which allows him to obtain a subproblem in which it is possible to define the theoretical compression limit.</strong> For this purpose, Shannon introduces the source that generates the message. Furthermore, the coding scheme which converts the symbols into codewords is generated on the information of the source and not on the information obtained from the message. <strong>Therefore, the coding scheme being defined before the generation of the message can be considered as an integral part of the communication language.</strong> Then, Shannon formalizes the concept of information, for this purpose he develops a variable that uniquely defines the message transmitted in the presence of an encoding scheme. The solution developed by Shannon is to consider information as a measure of a variation. The function generated that performs this measurement is called entropy H. The following sentence, taken from the article &quot;A Mathematical Theory of Communication”, makes us understand Shannon's idea of entropy.</p>
<p><em>“In the limiting case where one probability is unity (certainty) and all the others zero (impossibility), then H is zero (no uncertainty at all- no freedom of choice - no information).”</em></p>
<p><strong>With regard to the subproblem he defined, Shannon manages to define a theoretical compression limit by developing the source coding theorem.</strong> This theorem proves that entropy defines the minimum average length of the codewords that replace the symbols in the compressed message. Thus, given a source X of random variables i.i.d. which generates a message of length N the compressed message cannot be longer than NH(X). The encoding scheme being defined before message generation is not part of the compressed message.</p>
<p>Application of the theory developed by Shannon when the source is not known
When the source is not known, it is possible to calculate the zero order empirical entropy H0(m), in which the frequencies are obtained from the message m to be transmitted. In this case, using the frequencies of the symbols in the sequence the coding scheme is developed after the message has been generated therefore it must be part of the compressed message. Consequently, the compressed message is defined by NH0(M)+encoding scheme. Being the value of H0(m) very close to the value of H(X) the coding scheme represents a redundancy, which is also called inefficiency of the entropy coding. <strong>In practice, the non-knowledge of the source that generates the message determines the presence of a redundancy in the compressed message.</strong>
Furthermore, the length of the coding scheme depends on the language used, therefore, it is not possible to define it precisely. Consequently, it’s not possible to define a limit on the length of the compressed message. <strong>Therefore, using the formalism introduced by Shannon, we have shown that the compression limit of a sequence whose source is unknown is not computable.</strong></p>
<h2>Difference between the source entropy H(X) and the zero order empirical entropy H0(m)</h2>
<p>The value of NH(X) represents the compressed message. <strong>So entropy, in this case, defines message information in a more general sense, not just Shannon information.</strong> Unfortunately, this method does not represent the general case of information transmission, but represents a subproblem in which both the encoder and the decoder know the source that generates the message.</p>
<p>The value of NH0(m) does not represent the compressed message. <strong>Therefore, the zero-order empirical entropy represents only the average value of the Shannon information of the single symbol.</strong> Consequently,  the zero-order empirical entropy has a less general meaning than the entropy of the source. However, in this case, the problem of information transmission is being addressed in a much more general way than in the case of source coding.</p>
<p>To demonstrate what has just been said, the following example is given: let us take a uniform source X of random variables i.i.d. which generates a message of length N. Of course, this sequence cannot be compressed. Thus, on average the compressed message must have a length greater than or equal to N. In the first case, the encoder and the decoder know the source and therefore we can apply the source encoding. The result obtained is that all the messages have length NH(X) and since H(X)=1 (we use the dimension of the alphabet as the base of the entropy) the compressed message has a length N. So, in this case , we reach the theoretical compression limit. In the second case,both the encoder and the decoder do not know the source. Consequently, the encoder must use the value of the frequencies of the symbols in the message to calculate the entropy. In this way, the zero order empirical entropy H0(m) is obtained. The source is uniform but only a small amount of the generated messages have uniform symbol distribution. Therefore, the average value of the zero-order empirical entropy H0(m) of the messages will be less than H(X). Consequently, if we do not consider the coding scheme as part of the compressed message, we obtain an illogical result, in fact, we have NH0(m)&lt;N. In practice, we managed to compress a random sequence. <strong>The error depends on the fact that, in this second case, we obtained the coding scheme after the message was generated therefore, it must be part of the compressed message.</strong> In conclusion, to obtain a correct result, the compressed string must be defined by NH0(m)+coding scheme whose length is greater than N. Therefore, we have a redundancy due to non-knowledge of the source.</p>
<h2>Modern approach to information theory</h2>
<p>One of the most important aspects covered is to understand that source coding is a subproblem with respect to the problem of information transmission in its most general form. <strong>Consequently, when the source is not known, only the zero order empirical entropy can be calculated, a parameter that has a much more limited value than the entropy of the source.</strong> Indeed, the value obtained by multiplying the zero-order empirical entropy by the message length NH0(m) does not represent the compressed message. In this case, the coding scheme must also be part of the compressed message, having been defined after the generation of the message and therefore cannot be included in the communication language. This approach represents an important change of point of view. In fact, it was absolutely normal, even when the source was not known, to consider the compressed message only as NH0(m) without considering the coding scheme as is done with source coding.</p>
<p>This change of point of view was necessary with the arrival of a new theory that makes it possible to reduce the redundancy that is generated when the source is not known. This theory can only be applied when the alphabet is greater than or equal to 3. <strong>The purpose of this theory is to make the encoded sequence NH0(m) and the coding scheme interact with each other more efficiently.</strong></p>
<p>Now, I will explain the basis of this theory. If we have to perform entropy coding on a sequence of length N and alphabet A, whose source we do not know, the only information we have is that the sequence will be part of one of |A|^N possible sequences. <strong>Thus, the only possible way for a transform, to improve on average the length of the compressed sequence (encoded sequence+coding scheme), using an entropic coding, is to transform the set of all possible sequences into a new set of the same size composed of sequences that on average can be compressed in less space.</strong> In this way, even if we don't know the source that generates the sequence, we know that if we apply this transform, we can, on average, obtain a compressed message of smaller length than the compressed message of the untransformed sequence.</p>
<p>The set having these characteristics is the set of dimension |A|^N composed of sequences of length N+K. Increasing the length of the sequence also increases the size of the set that includes all possible sequences, which becomes |A|^N+K. Therefore, from this set it is possible to select a subset of size |A|^N composed of sequences having the smallest value of the zero order empirical entropy .</p>
<p>In this way, we obtain the following result: given a message m of length N generated by a source X (unknown) of random variables i.i.d., applying the described transform f(m), we obtain on average:</p>
<p><strong>NH(X)&lt; Avg(NtH0(f(m)+ coding scheme)&lt; Avg(NH0(m)+coding scheme)</strong></p>
<p>With Nt&gt;N</p>
<p>Avg(NH0(m)+coding scheme)=mean value of the encoded sequence m+coding scheme</p>
<p>Avg(NtH0(f(m)+ coding scheme)=mean value of the encoded transformed sequence f(m)+coding scheme</p>
<p><strong>NH(X) is the compression limit that is not known, in fact, we have set the condition that the source is not known.</strong> As mentioned at the beginning, when the source is not known, in the current state of knowledge, it is not possible to define a compression limit.</p>
<p>Now, we prove the obtained result experimentally. Let's take a sequence of length 3 and alphabet 3, the possible sequences are 27. If we increase the length to 4 and keep the alphabet at 3, the possible sequences become 81. Of these 81, we select the 27 with the smallest value of H0(m). In this way, the two sets have the same number of elements. Thus, we can define a one-to-one relationship between the sequences of the two sets. The following table shows the 27 elements of the two sets. In the first column, we have message m, in the second column, we have NH0(m), in the third column, we have the transformed message f(m) and in the fourth column, we have NtH0(f(m)) of the transformed message f(m).</p>
<p><a href="https://i.sstatic.net/uDzA7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/uDzA7.png" alt="enter image description here" /></a></p>
<p>The average value of zero order empirical entropy multiplied by the string length N=3 of the messages m is:
Avg(NH0(m))=2.893
with N=3.
The average value of zero order empirical entropy multiplied by the length of the string Nt=4 of the transformed messages f(m) is:
Avg(NtH0(f(m))=2.884
con Nt=4
Thus, you can see that although the transformed messages are longer, the average value of zero-order empirical entropy multiplied by the message length is, on average, smaller when the transform is applied. <strong>Consequently, even if we do not know the source, we know that by applying the transform, we obtain, on average, a reduction in the value of zero-order empirical entropy multiplied by the length of the message.</strong> Therefore, the length of the encoded message (symbols replaced by codewords) decreases.</p>
<p>Now, let's look at the encoding scheme, in this case making an evaluation is more difficult because the length of the encoding scheme depends on the compression method used. But, we know that, from a theoretical point of view, the parameter that most influences the length of the encoding scheme is the size of the alphabet. Therefore, we calculate the average size of the alphabet A in the two sets.
The mean value of the alphabet size |A|, in the case of messages in the first column of the table, is:
Avg(|A|)=2.1
The mean value of the alphabet size |A|, in the case of transformed messages f(m) in the third column of the table, is:
Avg(|A|)=1.89
The result obtained is not valid only for the reported case. <strong>Indeed, whatever the size of the alphabet, the transformed set being composed of longer sequences always has a greater number of type classes with a number of symbols less than |A|.</strong> With type class, we mean a set of strings that all have the same symbol frequency, for example, string 113 and string 131 belong to the same type class in fact, both have symbol frequency 1=2/3 and 3=1/ 4.</p>
<p>Therefore, being on average NH0(f(m))&lt;NH0(m) and coding scheme f(m) &lt; coding scheme m, we have experimentally demonstrated the following inequality:</p>
<p><strong>NH(X)&lt; Avg(NH0(f(m)+ coding scheme)&lt; Avg(NtH0(m)+coding scheme)</strong></p>
<p>In this way, the set of transformed messages has an average compressed message length, using entropy encoding, less than the set of untransformed messages. Consequently, when the source is not known, if the described transform is applied, a reduction of the compressed message is obtained on average. Therefore, we are able to reduce the inefficiency caused by not knowing the source.</p>
<p>In conclusion, the question we posed at the beginning, about the existence of a minimum compression length of a sequence, represents a problem that has not yet been solved. However, new developments regarding the theory of information, managing to reduce the inefficiency that is created when we don’t know the source, have made it possible to take a significant step forward on this topic.</p>

CC BY-SA 4.0
2023-04-27T14:18:56.753Z
2023-05-07T15:32:58.623Z
2023-05-07T15:32:58.623Z
Aida
<p>For a long time I have been theorizing, that the 1:2 theoretical lossless limit might be exceeded by compressing the &quot;noise data&quot; into dimensional structures at levels above the original data.
For example: The indexing of repeated data patterns to reduce the size of the archive is effective. But the notion that &quot;Noise data can not be compressed&quot; is not necessarily true...
If noise data of a given file is split into multiple, similar, noise-plates...A complex 3-dimensional transposition algorithm could arrange the 2-D plates in a 3-D cube, and find rules that run through the z-dimension of the plates to define how a set of rules might yield the initial set of plates, from a projection through a fewer number of plates in the archive. Thus, some of the 2-dimensional noise data is compressed into 3-dimensional projection rules.
The notion that the noise data is &quot;in-compressible&quot; does not stand to reason, because as long as there is data, there is potential for compression.</p>

CC BY-SA 4.0
2024-10-20T23:42:14.827Z
2024-10-20T23:42:14.827Z
Byron Davis
<p>I am not sure if anyone has yet explained why the magical number seems to be exactly 1:2 and not, for example, 1:1.1 or 1:20.</p>

<p>One reason is that in many typical cases <em>almost half of the digitised data is <strong>noise</em></strong>, and noise (by definition) cannot be compressed.</p>

<p>I did a very simple experiment:</p>

<ul>
<li><p>I took a <a href="http://en.wikipedia.org/wiki/Gray_card" rel="noreferrer">grey card</a>. To a human eye, it looks like a plain, neutral piece of grey cardboard. In particular, there is <strong>no information</strong>.</p></li>
<li><p>And then I took a normal scanner – exactly the kind of device that people might use to digitise their photos.</p></li>
<li><p>I scanned the grey card. (Actually, I scanned the grey card together with a postcard. The postcard was there for sanity-checking so that I could make sure the scanner software does not do anything strange, such as automatically add contrast when it sees the featureless grey card.)</p></li>
<li><p>I cropped a 1000x1000 pixel part of the grey card, and converted it to greyscale (8 bits per pixel).</p></li>
</ul>

<p>What we have now should be a fairly good example of what happens when you study a <em>featureless part of a scanned black &amp; white photo</em>, for example, clear sky. In principle, there should be exactly nothing to see.</p>

<p>However, with a larger magnification, it actually looks like this:</p>

<p><img src="https://i.sstatic.net/IOIux.png" alt="30x30 crop, magnified by factor 10"></p>

<p>There is no clearly visible pattern, but it does not have a uniform grey colour. Part of it is most likely caused by the imperfections of the grey card, but I would assume that most of it is simply noise produced by the scanner (thermal noise in the sensor cell, amplifier, A/D converter, etc.). Looks pretty much like Gaussian noise; here is the histogram (in <em>logarithmic</em> scale):</p>

<p><img src="https://i.sstatic.net/Kt00F.png" alt="histogram"></p>

<p>Now if we <em>assume</em> that each pixel has its shade picked i.i.d. from this distribution, how much entropy do we have? My Python script told me that we have as much as <strong>3.3 bits of entropy per pixel</strong>. And that's a lot of noise.</p>

<p>If this really was the case, it would imply that no matter which compression algorithm we use, the 1000x1000 pixel bitmap would be compressed, in the best case, into a 412500-byte file. And what happens in practice: I got a 432018-byte PNG file, pretty close.</p>

<hr>

<p>If we over-generalise slightly, it seems that no matter which black &amp; white photos I scan with this scanner, I will get the sum of the following:</p>

<ul>
<li>"useful" information (if any),</li>
<li>noise, approx. 3 bits per pixel.</li>
</ul>

<p>Now even if your compression algorithm squeezes the useful information into &lt;&lt; 1 bits per pixel, you will still have as much as 3 bits per pixel of incompressible noise. And the uncompressed version is 8 bits per pixel. So the compression ratio will be in the ballpark of 1:2, no matter what you do.</p>

<hr>

<p>Another example, with an attempt to find over-idealised conditions:</p>

<ul>
<li>A modern DSLR camera, using the lowest sensitivity setting (least noise).</li>
<li>An out-of-focus shot of a grey card (even if there was some visible information in the grey card, it would be blurred away).</li>
<li>Conversion of the RAW file into a 8-bit greyscale image, without adding any contrast. I used typical settings in a commercial RAW converter. The converter tries to reduce noise by default. Moreover, we are saving the end result as an 8-bit file – we are, in essence, <em>throwing away the lowest-order bits</em> of the raw sensor readings!</li>
</ul>

<p>And what was the end result? It looks much better than what I got from the scanner; the noise is less pronounced, and there is exactly nothing to be seen. Nevertheless, the Gaussian noise is there:</p>

<p><img src="https://i.sstatic.net/dmXqk.png" alt="30x30 crop, magnified by factor 10">
<img src="https://i.sstatic.net/oudH2.png" alt="histogram"></p>

<p>And the entropy? <strong>2.7 bits per pixel</strong>. File size in practice? 344923 bytes for 1M pixels. In a truly best-case scenario, with some cheating, we pushed the compression ratio to 1:3.</p>

<hr>

<p>Of course all of this has exactly nothing to do with TCS research, but I think it is good to keep in mind what <em>really</em> limits the compression of real-world digitised data. Advances in the design of fancier compression algorithms and raw CPU power is not going to help; if you want to save all the noise losslessly, you cannot do much better than 1:2.</p>

CC BY-SA 3.0
2011-06-18T23:37:34.977Z
cool! if the noise is gaussian, my feeling is that projecting on the first k singular vectors (or a similar more fancy technique) would remove a lot of the noise. a quick google scholar search revealed an article by M. Elad and M. Aharon, that uses the projection method + some Bayesian stats trickery: http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=4011956. supposedly, in 2006 it was "state of the art". of course, it's not lossless, but Jukka's data shows that if you insist on small size you need to lose at least the noise.
Sasho Nikolov
CC BY-SA 3.0
2011-06-19T04:14:00.153Z
Your examples are only about lossless compression of *images*. I will reluctantly grant you their generalization to any data coming from physical sensors (sound, image, video, yet probably with a distinct factor) but there are (many?) other fields where compression is applied, with a much better ratio than 1:2 (natural language comes to mind), because there is less noise.
J.y B.y
CC BY-SA 3.0
2011-06-19T11:15:27.263Z
@Jeremy: The original question explicitly mentioned "Lossless compression of digitized data such as video, digitized film, and audio" in conjunction with the ratio 1:2.
Jukka Suomela
CC BY-SA 3.0
2011-06-19T14:18:11.347Z
@Jukka: +1: Beautiful experiment! @Sasho: for medical images, the conventional wisdom is that you can't lose anything, even if it's very likely just noise.
Peter Shor 
CC BY-SA 3.0
2011-06-19T20:50:59.510Z
Very nice and clear explanation!
Marzio De Biasi
CC BY-SA 3.0
2011-06-20T14:26:27.503Z
Very very nice explanation! It's a pitty I can't vote you twice! :)
Auron
CC BY-SA 3.0
2011-06-22T12:23:10.143Z
One more comment: this is really unavoidable for medical images. If you don't use enough precision to have a substantial amount of this noise in medical images, then you're probably losing some actual relevant detail, which you would really want to keep.
Peter Shor 
CC BY-SA 3.0
2014-12-18T19:44:03.100Z
The notion that half the data is noise seems wrong when you're talking about images.  If you store a photograph at 16 bits per color channel, most of the time, each value will be almost identical to the value next to it.  If only the low-order two or three bits are really changing regularly, I'd expect to get on the order of 5.3:1 compression even if you can find no patterns in those remaining three bits at all (which is probably conservative).
dgatwood
CC BY-SA 3.0
2017-05-04T19:16:55.083Z
So, what would be the maximum compression ratio for a randomly (uniform) generated text?
skan
CC BY-SA 3.0
2017-08-19T22:01:27.703Z
what does "<< 1 bits per pixel" mean? "less than 1 bits" seems wrong. is `<<` a bit shift operator? so then, "more than 1 bits per pixel"? ">1 bits" would seem better.
Dave Cousineau
CC BY-SA 3.0
2011-06-18T20:06:29.373Z
2011-06-18T21:05:44.633Z
2011-06-18T21:05:44.633Z
Jukka Suomela
<p>Lately I've been dealing with compression-related algorithms, and I was wondering which is <strong>the best compression ratio that can be achievable by lossless data compression.</strong></p>

<p>So far, the only source I could find on this topic was the Wikipedia:</p>

<blockquote>
  <p>Lossless compression of digitized data
  such as video, digitized film, and
  audio preserves all the information,
  but <strong>can rarely do much better than 1:2 
  compression</strong> because of the intrinsic
  entropy of the data.</p>
</blockquote>

<p>Unfortunately, <a href="http://en.wikipedia.org/wiki/Data_compression_ratio">Wikipedia's article</a> doesn't contain a reference or citation to support this claim. I'm not a data-compression expert, so I'd appreciate any information you can provide on this subject, or if you could point me to a more reliable source than Wikipedia.</p>

CC BY-SA 3.0
2011-06-17T16:25:04.993Z
I'm not sure if Theoretical Computer Science is the best site to ask this kind of questions. Feel free to vote on close or to migrate this question to a more suitable site, if necessary.
Auron
CC BY-SA 3.0
2011-06-17T16:33:25.863Z
This may be what you're looking for: http://en.wikipedia.org/wiki/Entropy_encoding. The key word is *entropy*.
Hsien-Chih Chang 張顯之
CC BY-SA 3.0
2011-06-17T17:12:22.097Z
I don't know what would be a more suitable site, unfortunately. The [quantization error](http://en.wikipedia.org/wiki/Quantization_error) is a source of entropy which would probably preclude large compression ratios.
Peter Shor 
CC BY-SA 3.0
2011-06-17T17:17:26.527Z
One point is that, in general, one cannot always compress data to any ratio better than 1. Otherwise, you could imagine compressing your data, then compressing the compression, and so on until you've gotten it down to an arbitrarily small size, which we know is impossible.
Lev Reyzin
CC BY-SA 3.0
2011-06-17T18:32:43.370Z
Do you need lossless data compression for which kind of data? Images, music, speech, generic data, ... ? However, for a high level introduction see http://www.data-compression.com/theory.html (and resources at the bottom of the pages)
Marzio De Biasi
CC BY-SA 3.0
2011-06-18T08:30:40.817Z
@Vor Images. More specifically, medical images. I'll take a look to that page. Thanks.
Auron
CC BY-SA 3.0
2015-05-15T21:36:27.140Z
I don't know what the theoretical maximum lossless compression ratio is, but I do know that I downloaded Elephant's Dream 1080p, and compressed it with x264 lossless (using yuv444p as the intermediate) and it went from about 90GB uncommpressed, to 7.35 which is a compression ratio of 12:1
MarcusJ
CC BY-SA 3.0
2015-09-23T16:03:03.383Z
See these questions on StackExchange sites: [DSP](http://dsp.stackexchange.com/questions/3474/what-are-some-typical-lossless-compression-ratios), and [StackOverflow](http://stackoverflow.com/questions/18978731/what-can-be-the-least-possible-value-of-data-compression-ratio-for-any-real-data). Potential for >2X compression ratio exists, but such techniques have huge overhead. See my answer there.
user984260
<it.information-theory><data-streams>
Which is the limit of lossless compression data? (if there exists such a limit)
Auron
# Which is the limit of lossless compression data? (if there exists such a limit)

(Asked by: username_0 on 2011-06-17)

Lately I've been dealing with compression-related algorithms, and I was wondering which is **the best compression ratio that can be achievable by lossless data compression.**

So far, the only source I could find on this topic was the Wikipedia:

> Lossless compression of digitized data
> such as video, digitized film, and
> audio preserves all the information,
> but **can rarely do much better than 1:2
> compression** because of the intrinsic
> entropy of the data.

Unfortunately, [Wikipedia's article](http://en.wikipedia.org/wiki/Data_compression_ratio) doesn't contain a reference or citation to support this claim. I'm not a data-compression expert, so I'd appreciate any information you can provide on this subject, or if you could point me to a more reliable source than Wikipedia.

**Tags:** it.information-theory, data-streams

> **Comments:**
> **username_0**: I'm not sure if Theoretical Computer Science is the best site to ask this kind of questions. Feel free to vote on close or to migrate this question to a more suitable site, if necessary.  
> **username_1**: This may be what you're looking for: http://en.wikipedia.org/wiki/Entropy_encoding. The key word is *entropy*.  
> **username_2**: I don't know what would be a more suitable site, unfortunately. The [quantization error](http://en.wikipedia.org/wiki/Quantization_error) is a source of entropy which would probably preclude large compression ratios.  
> **username_3**: One point is that, in general, one cannot always compress data to any ratio better than 1. Otherwise, you could imagine compressing your data, then compressing the compression, and so on until you've gotten it down to an arbitrarily small size, which we know is impossible.  
> **username_4**: Do you need lossless data compression for which kind of data? Images, music, speech, generic data, ... ? However, for a high level introduction see http://www.data-compression.com/theory.html (and resources at the bottom of the pages)  
> **username_0**: @Vor Images. More specifically, medical images. I'll take a look to that page. Thanks.  
> **username_5**: I don't know what the theoretical maximum lossless compression ratio is, but I do know that I downloaded Elephant's Dream 1080p, and compressed it with x264 lossless (using yuv444p as the intermediate) and it went from about 90GB uncommpressed, to 7.35 which is a compression ratio of 12:1  
> **username_6**: See these questions on StackExchange sites: [DSP](http://dsp.stackexchange.com/questions/3474/what-are-some-typical-lossless-compression-ratios), and [StackOverflow](http://stackoverflow.com/questions/18978731/what-can-be-the-least-possible-value-of-data-compression-ratio-for-any-real-data). Potential for >2X compression ratio exists, but such techniques have huge overhead. See my answer there.  

---

## 7 answers

### Answer by username_13 on 2011-06-18. Score: 35 | Accepted answer

I am not sure if anyone has yet explained why the magical number seems to be exactly 1:2 and not, for example, 1:1.1 or 1:20.

One reason is that in many typical cases *almost half of the digitised data is **noise***, and noise (by definition) cannot be compressed.

I did a very simple experiment:

* I took a [grey card](http://en.wikipedia.org/wiki/Gray_card). To a human eye, it looks like a plain, neutral piece of grey cardboard. In particular, there is **no information**.
* And then I took a normal scanner – exactly the kind of device that people might use to digitise their photos.
* I scanned the grey card. (Actually, I scanned the grey card together with a postcard. The postcard was there for sanity-checking so that I could make sure the scanner software does not do anything strange, such as automatically add contrast when it sees the featureless grey card.)
* I cropped a 1000x1000 pixel part of the grey card, and converted it to greyscale (8 bits per pixel).

What we have now should be a fairly good example of what happens when you study a *featureless part of a scanned black & white photo*, for example, clear sky. In principle, there should be exactly nothing to see.

However, with a larger magnification, it actually looks like this:

![30x30 crop, magnified by factor 10](https://i.sstatic.net/IOIux.png)

There is no clearly visible pattern, but it does not have a uniform grey colour. Part of it is most likely caused by the imperfections of the grey card, but I would assume that most of it is simply noise produced by the scanner (thermal noise in the sensor cell, amplifier, A/D converter, etc.). Looks pretty much like Gaussian noise; here is the histogram (in *logarithmic* scale):

![histogram](https://i.sstatic.net/Kt00F.png)

Now if we *assume* that each pixel has its shade picked i.i.d. from this distribution, how much entropy do we have? My Python script told me that we have as much as **3.3 bits of entropy per pixel**. And that's a lot of noise.

If this really was the case, it would imply that no matter which compression algorithm we use, the 1000x1000 pixel bitmap would be compressed, in the best case, into a 412500-byte file. And what happens in practice: I got a 432018-byte PNG file, pretty close.

---

If we over-generalise slightly, it seems that no matter which black & white photos I scan with this scanner, I will get the sum of the following:

* "useful" information (if any),
* noise, approx. 3 bits per pixel.

Now even if your compression algorithm squeezes the useful information into << 1 bits per pixel, you will still have as much as 3 bits per pixel of incompressible noise. And the uncompressed version is 8 bits per pixel. So the compression ratio will be in the ballpark of 1:2, no matter what you do.

---

Another example, with an attempt to find over-idealised conditions:

* A modern DSLR camera, using the lowest sensitivity setting (least noise).
* An out-of-focus shot of a grey card (even if there was some visible information in the grey card, it would be blurred away).
* Conversion of the RAW file into a 8-bit greyscale image, without adding any contrast. I used typical settings in a commercial RAW converter. The converter tries to reduce noise by default. Moreover, we are saving the end result as an 8-bit file – we are, in essence, *throwing away the lowest-order bits* of the raw sensor readings!

And what was the end result? It looks much better than what I got from the scanner; the noise is less pronounced, and there is exactly nothing to be seen. Nevertheless, the Gaussian noise is there:

![30x30 crop, magnified by factor 10](https://i.sstatic.net/dmXqk.png)
![histogram](https://i.sstatic.net/oudH2.png)

And the entropy? **2.7 bits per pixel**. File size in practice? 344923 bytes for 1M pixels. In a truly best-case scenario, with some cheating, we pushed the compression ratio to 1:3.

---

Of course all of this has exactly nothing to do with TCS research, but I think it is good to keep in mind what *really* limits the compression of real-world digitised data. Advances in the design of fancier compression algorithms and raw CPU power is not going to help; if you want to save all the noise losslessly, you cannot do much better than 1:2.

> **Comments:**
> **username_14**: cool! if the noise is gaussian, my feeling is that projecting on the first k singular vectors (or a similar more fancy technique) would remove a lot of the noise. a quick google scholar search revealed an article by M. Elad and M. Aharon, that uses the projection method + some Bayesian stats trickery: http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=4011956. supposedly, in 2006 it was "state of the art". of course, it's not lossless, but Jukka's data shows that if you insist on small size you need to lose at least the noise.  
> **username_9**: Your examples are only about lossless compression of *images*. I will reluctantly grant you their generalization to any data coming from physical sensors (sound, image, video, yet probably with a distinct factor) but there are (many?) other fields where compression is applied, with a much better ratio than 1:2 (natural language comes to mind), because there is less noise.  
> **username_13**: @Jeremy: The original question explicitly mentioned "Lossless compression of digitized data such as video, digitized film, and audio" in conjunction with the ratio 1:2.  
> **username_2**: @Jukka: +1: Beautiful experiment! @Sasho: for medical images, the conventional wisdom is that you can't lose anything, even if it's very likely just noise.  
> **username_4**: Very nice and clear explanation!  
> **username_0**: Very very nice explanation! It's a pitty I can't vote you twice! :)  
> **username_2**: One more comment: this is really unavoidable for medical images. If you don't use enough precision to have a substantial amount of this noise in medical images, then you're probably losing some actual relevant detail, which you would really want to keep.  
> **username_15**: The notion that half the data is noise seems wrong when you're talking about images.  If you store a photograph at 16 bits per color channel, most of the time, each value will be almost identical to the value next to it.  If only the low-order two or three bits are really changing regularly, I'd expect to get on the order of 5.3:1 compression even if you can find no patterns in those remaining three bits at all (which is probably conservative).  
> **username_8**: So, what would be the maximum compression ratio for a randomly (uniform) generated text?  
> **username_16**: what does "<< 1 bits per pixel" mean? "less than 1 bits" seems wrong. is `<<` a bit shift operator? so then, "more than 1 bits per pixel"? ">1 bits" would seem better.  

---

### Answer by username_7 on 2011-06-17. Score: 17

Do you already know about [Shannon's noiseless coding theorem](http://en.wikipedia.org/wiki/Shannon_noiseless_coding_theorem)? This theorem establistes theoretical limits on lossless compression. Some of the comments from the others seem to assume you know about this theorem, but from the question, I think it may be the answer you are looking for.

> **Comments:**
> **username_0**: I didn't know about that theorem. I guess Wikipedia's claim is not exactly correct, as the achievable compression ratio depends on the entropy of the data to be compressed.  
> **username_2**: I believe it's really quite hard to determine the intrinsic entropy of images -- it's much easier if the data is linear rather than 2-D.  
> **username_8**: So, what would be the maximum compression ratio for a randomly (uniform) generated text?  

---

### Answer by username_9 on 2011-06-18. Score: 10

Compression is just an *opportunistic* way of encoding things, and when asking for "the best compression ratio that can be achievable by lossless data compression", you need to be more specific about the context of the compression: the compression ratio is the ratio between the size of the compression and the size of a "raw" encoding, but the size of the "raw" encoding depends of the hypothesis on your object (i.e. the size of its domain, or the "size of the bag from which it comes"). As a simplistic example, consider the task of encoding a positive integer $n>0$:

1. You might use only one bit, if $n$ is the only integer you will ever encode, and you need only to remember that you encoded it.
2. The common practical solution is to use 8 bits, if the only integers you will ever encode are all between 1 and 256 (generalize to 16, 32 and 64 bits if you want).
3. If you do not have any hypothesis about the range in which falls the integer you will have to encode, a naive solution is to use $n+1$ bits ($n$ zeros followed by a one) to encode it in unary. This might not look yet as a compression, but it has the opportunistic aspect of compression: the smaller the value of $n$, the smaller the size of its unary encoding.
4. A more serious, general purpose, encoding scheme of integers is the *gamma* code: encode the value of $\lceil\log\_2 n\rceil$ in unary using $\lceil\log\_2 n\rceil+1$ bits, followed by $n$ in binary, using $\lceil\log\_2 n\rceil-1$ (you do not need the leftmost bit, which is always one, since you already know the value of $\lceil\log\_2 n\rceil$). This encoding uses in total $2\lceil\log\_2 n\rceil-1$ bits, and is a useful compression of $n$, often use in practice. (Note that in the litterature you will find those results noted $\lg n=\max(1,\lceil\log\_2 n\rceil)$ to make notations shorter.)
5. The gamma code is not *optimal*, in the sense that there are other codes which use less space for arbitrarily many integers, and more for only a finite amount. A very good reading on the topic is "An almost optimal algorithm for unbounded searching" by Jon Louis Bentley and Andrew Chi-Chih Yao from 1976 (I like in particularly their link between the complexity of search algorithms and the size of integer encodings: I find it one of the most simple and beautiful TCS results I know). The bottom line is that $2\lceil\log\_2 n\rceil-1$ bits is within a factor of two of the optimal, which most agree is enough in practice given the complexity of better solutions.
6. Yet, taking the "opportunistic" approach to its limit, there is an infinite number of compression schemes taking advantage of various hypotheses. One way to deal with this infinity of opportunistic encodings (i.e. compression scheme) is to require the encoding of the hypothesis itself, and to take into account the size of the encoding of the hypothesis in the total compression size. Formally, this corresponds to encode both the compressed data *and the decoder*, or more generally to encode a program which, when executed, outputs the uncompressed object: the smallest size of such a program is called the *[Kolmogorov's complexity](http://en.wikipedia.org/wiki/Kolmogorov_complexity)* $K$. This is a very theoretical construct in the sense that, without a bound on the execution time of the program, $K$ is not computable. An easy workaround around this notion is given by [Levin](http://en.wikipedia.org/wiki/Leonid_Levin)'s self-delimiting programs, where you consider only programs with a bounded execution time (for instance, within a constant factor of the length of the original instance, which is a lower bound on the complexity of the algorithm which needs to write each symbol).

There is a whole community working about Kolmogorov's complexity and its variants, and another community working on loss-less compression (the example on integers that I used has equivalent on many other data types), I barely scratched the surface, and others might add precisions (Kolmogorov is really not my specialty), but I hope that this might help you clarify your question, if not necessarily give you the answer you were hoping for :)


---

### Answer by username_10 on 2011-06-18. Score: 10

Think of a file as a string.

You can never do better than the Kolmogorov complexity of a string (this is by the definition of Komogorov complexity).

Fix a string length. So now we're only looking at strings of length n.

Half of all such strings can be compressed by at most 1 bit. 1/4 of all strings can be compressed by at most 2 bits. 1/8 of all such strings can be compressed by at most 3 bits.

So what fraction of strings (images, files, etc.) can be compressed at the ratio of 2:1 -- very, very few. So why does compression ever work? Because almost all data that real people are actually trying to compress is highly structured -- it doesn't look like a random file. The more random looking the data, the harder to compress. They go hand in hand. Most strings look random.

To see this in action, generate a random file using some random process. I mean a really, really random file. Now try to compress it using your favorite compression algorithm. It will either stay the same size or get bigger, almost all of the time.

On the flip side, there are highly compressible strings. Take the following string:
100000..000 (1 followed by a million zeros). The description of it fits in the previous sentence, and a computer could reconstruct it from that description (or one very much like it). Yet that description is nowhere near a million digits long.

The fact is that strings with that property (of being highly compressible) are extremely rare among all possible strings. The secondary fact is that almost all human-generated data is super, super compressible because it is so structured.


---

### Answer by username_4 on 2011-06-18. Score: 7

(just an extension of my comment)

(As pointed out by Joe in his answer) Shannon - in his 1948 paper, "[A Mathematical Theory of Communication](http://cm.bell-labs.com/cm/ms/what/shannonday/shannon1948.pdf)" formulated the theory of data compression and established that there is a fundamental limit to lossless data compression. This limit, called the entropy rate, is denoted by H. The exact value of H depends on the information source --- more specifically, the statistical nature of the source. It is possible to compress the source, in a lossless manner, with compression rate close to H. It is mathematically impossible to do better than H.

However some class of images (for example medical grayscale images) without high-contrast edges and with smooth level transitions can be compressed (not so efficiently).

**JPEG-LS** and **JPEG2000** seem to be the standards for lossless storage of medical images. See this table for a comparison of [compression ratios](http://www.accusoft.com/picmedxfeatures.htm) (the JPEG-LS achieves a slightly better compression).

Using "lossless medical image compression" I found the following articles that may help you:

A recent (2011) survey on medical image compression techniques: [Two Dimensional Medical Image Compression Techniques - A Survey](http://www.icgst.com/gvip/Volume11/Issue1/P1151026155.pdf)

*... This paper presents overview of various compression techniques based
on DCT, DWT, ROI and Neural Networks for two dimensional (2D) still medical images.*

A detailed presentation of two standard lossless compression algorithms: JPEG-LS and JPG2000 in lossless mode: [Lossless Compression of Grayscale Medical Images - Effectiveness of Traditional and State of the Art Approaches](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34.4801&rep=rep1&type=pdf)

*... Three thousand, six hundred and seventy-nine (3,679) single frame grayscale images from multiple anatomical regions,modalities and vendors, were tested. ...*

Another survey: [A Survey of Contemporary Medical Image Compression Techniques](http://kanchan-iitg.tripod.com/sitebuildercontent/sitebuilderfiles/imagecompression.pdf)

**EDIT**

Perhaps you are still wondering "What the hell is the entropy of an image?" ... OK, it's the *amount of information contained in the image* ... but to better understand it, you should read something about the 3 phases usually used in **image compression**:

* transformation (for example Discrete Wavelet Transformation)
* quantization
* entropy encoding

You can use Google to search for a tutorial or book on Image compression (for example [a quick tutorial](http://www.debugmode.com/imagecmp/index.htm)), or try to watch an online technical video (for example [Lecture 16 - Introduction to Image and Video coding](http://www.youtube.com/watch?v=SnstUsMJ4V4)).


---

### Answer by username_11 on 2023-04-27. Score: 0

# Compression limit of an individual sequence

What is the compression limit of a sequence?

Two answers can be given to this question:

1. **The compression limit of a sequence is an unsolved problem.** Furthermore, it has been shown that this limit cannot be calculated.
2. **Shannon defined a subproblem of great practical relevance, in which it is possible to define a theoretical limit (source coding theorem).** This subproblem is purely probabilistic and is called source coding.

## Definition of the information transfer problem in its most general form

To understand these two answers it is essential to introduce the problem of information transmission in its most general form. For the transmission of information to take place between two points, it is essential that the two subjects share a communication language. This requirement is necessary, without a language of communication, the transmitted message is not understood and therefore does not carry any information. **Consequently, the information transmission problem, in its most general form, studies the transfer of information in any form between two points that share a language of communication.**

The problem with this definition is that the concept of "information in any form" is difficult to formalize mathematically. **For this reason, it is essential to introduce a first simplification of the problem, in which the information is defined as a numerical sequence.** In this way, a subproblem is obtained, in which the concept of information is well-defined and can be formalized from the mathematical point of view.

Consequently, the two elements necessary for the transfer of information are: a compressed sequence which carries the information and a communication language known by both the encoder and the decoder.

**Compressed sequence:** represents any information derived from the sequence to be transmitted. From a practical point of view, any information obtained from the sequence that is useful for the decoder to go back to the original message must be considered part of the compressed message.

**Communication language:** represents a set of rules that allows communication and therefore the transfer of information between two subjects. From a practical point of view, any information present before the generation of the message can be considered part of the communication language.

## Source coding

**Shannon in his famous article “A Mathematical Theory of Communication” introduces a further modification to the information transfer problem, which allows him to obtain a subproblem in which it is possible to define the theoretical compression limit.** For this purpose, Shannon introduces the source that generates the message. Furthermore, the coding scheme which converts the symbols into codewords is generated on the information of the source and not on the information obtained from the message. **Therefore, the coding scheme being defined before the generation of the message can be considered as an integral part of the communication language.** Then, Shannon formalizes the concept of information, for this purpose he develops a variable that uniquely defines the message transmitted in the presence of an encoding scheme. The solution developed by Shannon is to consider information as a measure of a variation. The function generated that performs this measurement is called entropy H. The following sentence, taken from the article "A Mathematical Theory of Communication”, makes us understand Shannon's idea of entropy.

*“In the limiting case where one probability is unity (certainty) and all the others zero (impossibility), then H is zero (no uncertainty at all- no freedom of choice - no information).”*

**With regard to the subproblem he defined, Shannon manages to define a theoretical compression limit by developing the source coding theorem.** This theorem proves that entropy defines the minimum average length of the codewords that replace the symbols in the compressed message. Thus, given a source X of random variables i.i.d. which generates a message of length N the compressed message cannot be longer than NH(X). The encoding scheme being defined before message generation is not part of the compressed message.

Application of the theory developed by Shannon when the source is not known
When the source is not known, it is possible to calculate the zero order empirical entropy H0(m), in which the frequencies are obtained from the message m to be transmitted. In this case, using the frequencies of the symbols in the sequence the coding scheme is developed after the message has been generated therefore it must be part of the compressed message. Consequently, the compressed message is defined by NH0(M)+encoding scheme. Being the value of H0(m) very close to the value of H(X) the coding scheme represents a redundancy, which is also called inefficiency of the entropy coding. **In practice, the non-knowledge of the source that generates the message determines the presence of a redundancy in the compressed message.**
Furthermore, the length of the coding scheme depends on the language used, therefore, it is not possible to define it precisely. Consequently, it’s not possible to define a limit on the length of the compressed message. **Therefore, using the formalism introduced by Shannon, we have shown that the compression limit of a sequence whose source is unknown is not computable.**

## Difference between the source entropy H(X) and the zero order empirical entropy H0(m)

The value of NH(X) represents the compressed message. **So entropy, in this case, defines message information in a more general sense, not just Shannon information.** Unfortunately, this method does not represent the general case of information transmission, but represents a subproblem in which both the encoder and the decoder know the source that generates the message.

The value of NH0(m) does not represent the compressed message. **Therefore, the zero-order empirical entropy represents only the average value of the Shannon information of the single symbol.** Consequently, the zero-order empirical entropy has a less general meaning than the entropy of the source. However, in this case, the problem of information transmission is being addressed in a much more general way than in the case of source coding.

To demonstrate what has just been said, the following example is given: let us take a uniform source X of random variables i.i.d. which generates a message of length N. Of course, this sequence cannot be compressed. Thus, on average the compressed message must have a length greater than or equal to N. In the first case, the encoder and the decoder know the source and therefore we can apply the source encoding. The result obtained is that all the messages have length NH(X) and since H(X)=1 (we use the dimension of the alphabet as the base of the entropy) the compressed message has a length N. So, in this case , we reach the theoretical compression limit. In the second case,both the encoder and the decoder do not know the source. Consequently, the encoder must use the value of the frequencies of the symbols in the message to calculate the entropy. In this way, the zero order empirical entropy H0(m) is obtained. The source is uniform but only a small amount of the generated messages have uniform symbol distribution. Therefore, the average value of the zero-order empirical entropy H0(m) of the messages will be less than H(X). Consequently, if we do not consider the coding scheme as part of the compressed message, we obtain an illogical result, in fact, we have NH0(m)The error depends on the fact that, in this second case, we obtained the coding scheme after the message was generated therefore, it must be part of the compressed message. In conclusion, to obtain a correct result, the compressed string must be defined by NH0(m)+coding scheme whose length is greater than N. Therefore, we have a redundancy due to non-knowledge of the source.

## Modern approach to information theory

One of the most important aspects covered is to understand that source coding is a subproblem with respect to the problem of information transmission in its most general form. **Consequently, when the source is not known, only the zero order empirical entropy can be calculated, a parameter that has a much more limited value than the entropy of the source.** Indeed, the value obtained by multiplying the zero-order empirical entropy by the message length NH0(m) does not represent the compressed message. In this case, the coding scheme must also be part of the compressed message, having been defined after the generation of the message and therefore cannot be included in the communication language. This approach represents an important change of point of view. In fact, it was absolutely normal, even when the source was not known, to consider the compressed message only as NH0(m) without considering the coding scheme as is done with source coding.

This change of point of view was necessary with the arrival of a new theory that makes it possible to reduce the redundancy that is generated when the source is not known. This theory can only be applied when the alphabet is greater than or equal to 3. **The purpose of this theory is to make the encoded sequence NH0(m) and the coding scheme interact with each other more efficiently.**

Now, I will explain the basis of this theory. If we have to perform entropy coding on a sequence of length N and alphabet A, whose source we do not know, the only information we have is that the sequence will be part of one of |A|^N possible sequences. **Thus, the only possible way for a transform, to improve on average the length of the compressed sequence (encoded sequence+coding scheme), using an entropic coding, is to transform the set of all possible sequences into a new set of the same size composed of sequences that on average can be compressed in less space.** In this way, even if we don't know the source that generates the sequence, we know that if we apply this transform, we can, on average, obtain a compressed message of smaller length than the compressed message of the untransformed sequence.

The set having these characteristics is the set of dimension |A|^N composed of sequences of length N+K. Increasing the length of the sequence also increases the size of the set that includes all possible sequences, which becomes |A|^N+K. Therefore, from this set it is possible to select a subset of size |A|^N composed of sequences having the smallest value of the zero order empirical entropy .

In this way, we obtain the following result: given a message m of length N generated by a source X (unknown) of random variables i.i.d., applying the described transform f(m), we obtain on average:

**NH(X)< Avg(NtH0(f(m)+ coding scheme)< Avg(NH0(m)+coding scheme)**

With Nt>N

Avg(NH0(m)+coding scheme)=mean value of the encoded sequence m+coding scheme

Avg(NtH0(f(m)+ coding scheme)=mean value of the encoded transformed sequence f(m)+coding scheme

**NH(X) is the compression limit that is not known, in fact, we have set the condition that the source is not known.** As mentioned at the beginning, when the source is not known, in the current state of knowledge, it is not possible to define a compression limit.

Now, we prove the obtained result experimentally. Let's take a sequence of length 3 and alphabet 3, the possible sequences are 27. If we increase the length to 4 and keep the alphabet at 3, the possible sequences become 81. Of these 81, we select the 27 with the smallest value of H0(m). In this way, the two sets have the same number of elements. Thus, we can define a one-to-one relationship between the sequences of the two sets. The following table shows the 27 elements of the two sets. In the first column, we have message m, in the second column, we have NH0(m), in the third column, we have the transformed message f(m) and in the fourth column, we have NtH0(f(m)) of the transformed message f(m).

[![enter image description here](https://i.sstatic.net/uDzA7.png)](https://i.sstatic.net/uDzA7.png)

The average value of zero order empirical entropy multiplied by the string length N=3 of the messages m is:
Avg(NH0(m))=2.893
with N=3.
The average value of zero order empirical entropy multiplied by the length of the string Nt=4 of the transformed messages f(m) is:
Avg(NtH0(f(m))=2.884
con Nt=4
Thus, you can see that although the transformed messages are longer, the average value of zero-order empirical entropy multiplied by the message length is, on average, smaller when the transform is applied. **Consequently, even if we do not know the source, we know that by applying the transform, we obtain, on average, a reduction in the value of zero-order empirical entropy multiplied by the length of the message.** Therefore, the length of the encoded message (symbols replaced by codewords) decreases.

Now, let's look at the encoding scheme, in this case making an evaluation is more difficult because the length of the encoding scheme depends on the compression method used. But, we know that, from a theoretical point of view, the parameter that most influences the length of the encoding scheme is the size of the alphabet. Therefore, we calculate the average size of the alphabet A in the two sets.
The mean value of the alphabet size |A|, in the case of messages in the first column of the table, is:
Avg(|A|)=2.1
The mean value of the alphabet size |A|, in the case of transformed messages f(m) in the third column of the table, is:
Avg(|A|)=1.89
The result obtained is not valid only for the reported case. **Indeed, whatever the size of the alphabet, the transformed set being composed of longer sequences always has a greater number of type classes with a number of symbols less than |A|.** With type class, we mean a set of strings that all have the same symbol frequency, for example, string 113 and string 131 belong to the same type class in fact, both have symbol frequency 1=2/3 and 3=1/ 4.

Therefore, being on average NH0(f(m))

**NH(X)< Avg(NH0(f(m)+ coding scheme)< Avg(NtH0(m)+coding scheme)**

In this way, the set of transformed messages has an average compressed message length, using entropy encoding, less than the set of untransformed messages. Consequently, when the source is not known, if the described transform is applied, a reduction of the compressed message is obtained on average. Therefore, we are able to reduce the inefficiency caused by not knowing the source.

In conclusion, the question we posed at the beginning, about the existence of a minimum compression length of a sequence, represents a problem that has not yet been solved. However, new developments regarding the theory of information, managing to reduce the inefficiency that is created when we don’t know the source, have made it possible to take a significant step forward on this topic.


---

### Answer by username_12 on 2024-10-20. Score: -1

For a long time I have been theorizing, that the 1:2 theoretical lossless limit might be exceeded by compressing the "noise data" into dimensional structures at levels above the original data.
For example: The indexing of repeated data patterns to reduce the size of the archive is effective. But the notion that "Noise data can not be compressed" is not necessarily true...
If noise data of a given file is split into multiple, similar, noise-plates...A complex 3-dimensional transposition algorithm could arrange the 2-D plates in a 3-D cube, and find rules that run through the z-dimension of the plates to define how a set of rules might yield the initial set of plates, from a projection through a fewer number of plates in the archive. Thus, some of the 2-dimensional noise data is compressed into 3-dimensional projection rules.
The notion that the noise data is "in-compressible" does not stand to reason, because as long as there is data, there is potential for compression.


---

