1
$\begingroup$

I know that the answer is no but I'm not sure why. Here's where I started. We know that all data with length $n$ Bits and minimum $1$ Bit can be compressed, either lossless or lossy. But how do I continue? Why is it impossible to compress all the data without loss?

$\endgroup$
  • 1
    $\begingroup$ either lossless or lossy don't get into lossy compression until you are sure why $n$ pigeons don't fit into $n-1$ holes with no two pigeons in the same hole. $\endgroup$ – greybeard Mar 30 '18 at 23:22
4
$\begingroup$

There are $2^n$ bitstrings of length $n$, but only $2^n-1$ bitstrings of length smaller than $n$. Hence there is no one-to-one mapping which maps every bitstring of length $n$ to a bitstring of strictly smaller length. In other words, for any (lossless) compression scheme there will always be a string which it doesn't compress.

$\endgroup$
3
$\begingroup$

Each string of bits can also be a number.

Then we add pigeonholes. For each possible original message create a pigeon. For a message up to $n$ bits that is $\sum^n_{i=1} {2^i}=2^{n+1}-2$ pigeons.

Now create a pigeonhole for each possible compressed message. If you have to compress (compressed message always has less bits then uncompressed) you only have $2^{n}-2$ pigeonholes.

because $2^{n+1}-2 > 2^{n}-2$ there will be pigeons sharing a hole. With lossless compression this is not allowed.

The reason compression works most of the time is that most messages that we want to compress are self redundant in some way. Compression algorithms look for those patterns and exploit them. However doing this forces other messages (that we don't generate) to become larger when using the same compressor.

$\endgroup$
  • 1
    $\begingroup$ A more generic way of saying what's in your last paragraph that's more in line with the rest of your answer, is that common lossless compression algorithms make some messages smaller at the cost of making other messages larger than their uncompressed forms. It's just that messages that become larger when "compressed" are unusual in practice (unless they are already compressed). $\endgroup$ – Derek Elkins Mar 31 '18 at 1:43
0
$\begingroup$

We know that all data with length n Bits and minimum 1 Bit can be compressed...

How do we know this? This isn't true for lossless compression. In fact for strings of length n, most of them are not compressible.

$\endgroup$
  • $\begingroup$ (Knowing the length to be $n > 0$, I'd drop one leading true bit: half the bit strings got shorter (and none got longer). (I know neither a "prefix code" achieving that nor a way to prove that such doesn't exist (other than hand-waving: dropping the first bit from all bit-strings that have at least one leaves you with a larger set (+ empty string)).)) $\endgroup$ – greybeard Apr 1 '18 at 15:43
  • $\begingroup$ Yeah, the prefix code gets in the way. Try it for say all strings where n<3. $\endgroup$ – Ray Apr 2 '18 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.