News for hackers. Stuff that matters.
Re:Gzip + poetry = awesome by mvleming on Friday October 25, 2013 @01:21AM (#6609902)
Wow, this is a incredible visualization of how compression works. I never understood how it worked before, but the simple mentioning of pointers and then that video was all it took for me.

I've always wondered if this is true: If we approach infinite computational power, does the amount of information we need to represent data decrease? (Excuse any incorrect use of my terminology here.) I think about a number like pi that, as far as we know, has an infinite number of digits, and theoretically speaking every message is contained in that number. So if we just get the pointer of where that message is contained in the number and then calculate the number up to that pointer then we'll have ourselves the message. Hence, more computational power, less information needed.

Re:Gzip + poetry = awesome by sillysaurus2 on Friday October 25, 2013 @01:37AM (#6609968)
There is a limit beyond which you can't compress data any further, called the Shannon limit.

Any sequence of bytes is just a number. So if you think of pi as an RNG, then the chances of finding a run of N digits equal to another number with N digits is (1/10) to the power of N, which quickly becomes intractible.

In reality the digits of pi are biased, so finding a particular number of N digits is even less likely.

It would be easier to search for that number by randomly seeding an RNG then searching the RNG output for the number. Then you could just store the seed+offset, which may be significantly less than the Shannon limit. But since the chance of encountering such a number is (1/256)^N, it quickly becomes impossible. And even if it weren't, the receiver would need to invoke the RNG [offset] times, which will be a massive number of times due to the probabilities involved. So it's not like you could precompute the index: the receiver still needs to compute the answer, which requires just as many computations as the sender.

In general, the closer you try to get to the Shannon limit, the more computation that is required. And perfect compression is impossible in practice except in constrained cases, so I'd speculate it requires infinite computational resources.

Re:Gzip + poetry = awesome by ot on Friday October 25, 2013 @04:23AM (#6610389)
> There is a limit beyond which you can't compress data any further, called the Shannon limit.

I think you are confusing things a bit here. The Shannon limit has nothing to do with lossless compression, it refer to communication in noisy channels.

What you are referring to is the Shannon entropy, but even that is not actually a lower bound to compression of actual data, because it is defined for stochastic sources.

When you have an actual string and you want to compress it, the only meaningful lower bound is the Kolmogorov complexity of the string, that is the size of the smallest program that generates that string. It is of course incomputable, but it is what you would get if you had infinite computing power.

Re:Gzip + poetry = awesome by sillysaurus2 on Friday October 25, 2013 @05:12AM (#6610519)
I appreciate you correcting my terminology, but beyond that you haven't actually disagreed with anything I've said.

Humans call it either the Shannon limit, or Shannon entropy, or Kolmogorov complexity of a string, or whatever other name humans have come up with for human names. The central point is there is some limit which you can't circumvent through trickery like "find it embedded within pi," regardless of what species you are, or what your species chooses to name fundamental limitations of nature.

A program to generate digits of pi is small, and pi embeds every possible string. But generating up to that offset of pi is impossible in practice. And it probably won't net you any savings anyway, since you'll still need to communicate the offset. The offset's length in digits is probably close to the length of the original string (after perfect compression), so it's unlikely you'd be able to circumvent Shannon entropy.

But, if you do manage to create a practical way to bypass Shannon entropy, I'd imagine it'll be headline news, along with netting you quite a lot of money.

Re:Gzip + poetry = awesome by iliis on Friday October 25, 2013 @08:22AM (#6611105)
If you're talking about Kolmogorov Complexity here, you can't really "circumvent" it. Kolmogorov Complexitiy of a string is basically defined as the size of the shortest possible representation of said string. If you manage to"bypass" the Kolmogorov Limit you actually just "lowered" it (well, it alwayws was by definition this low).

Your main point is totally valid however. You cannot compress infinitely. A simple proof: For any given N bits you can encode [at most] 2^N different strings. As there exist more than N strings there must be one which cannot be represented by N bits. As N can be arbitrarily large you'll always find strings which cannot be compressed lower than some chosen size. QED.

Re:Gzip + poetry = awesome by kevgnulldev on Friday October 25, 2013 @01:25PM (#6613007)
Re:Gzip + poetry = awesome by wging on Friday October 25, 2013 @01:47AM (#6609993)
>In reality the digits of pi are biased, so finding a particular number of N digits is even less likely.

This is actually not known to be true. In fact, it's conjectured that pi is normal[1]--meaning that we should expect every sequence of digits of a given length to be as likely as any other, no matter what base we're using.

So if you know the position at which the string you're interested in appears, you can just 'compress' by giving the location in the binary expansion of pi at which your message appears, and the length of your message in bits.

Where this fails, of course, is that you're likely to have to search a long time to find your message in pi, and you're also probably unlikely to be able to express your starting offset in fewer bits than it would take to write your full message.

[1] http://en.wikipedia.org/wiki/Normal_number

Re:Gzip + poetry = awesome by BuildTheRobots on Friday October 25, 2013 @05:33AM (#6610586)
> So if you know the position at which the string you're interested in appears, you can just 'compress' by giving the location in the binary expansion of pi at which your message appears, and the length of your message in bits.

It's a bit tongue in cheek, but this is exactly what piFS[1] does.

[1] https://github.com/philipl/pifs

Re:Gzip + poetry = awesome by wging on Friday October 25, 2013 @11:53AM (#6612314)
I love his commitment to the joke.
Re:Gzip + poetry = awesome by trentlott on Friday October 25, 2013 @10:23AM (#6611761)
That's beautiful.
Re:Gzip + poetry = awesome by sillysaurus2 on Friday October 25, 2013 @01:54AM (#6610016)
So pi containing 3.141592653579 is equally likely as pi containing 1415926535797, which is equally likely to contain ABCDEFGHIJKL for every random ABCDEFGHIJKL? Fascinating. Completely impossible to take advantage of, too, but fascinating.
Re:Gzip + poetry = awesome by p4bl0 on Friday October 25, 2013 @04:05AM (#6610340)
> Completely impossible to take advantage of

That depends on your goals, to do geeky things it's pretty cool :). I know my birth date (in the "ddmmyy" format) appears at the 262768th decimal of π.

By the way this example validates part of the answer of sillysaurus2 to mvleming: I need 6 digits to encode 6 other. Not that good a compression.

Re:Gzip + poetry = awesome by wging on Friday October 25, 2013 @04:54AM (#6610464)
If pi is normal, and the two strings are of equal length, then yes... not only that, but if pi is normal it's likely that each appears infinitely often.

By the way, sorry to point this out, but after 535 pi actually goes 5358979...

Re:Gzip + poetry = awesome by Someone on Saturday October 26, 2013 @03:40PM (#6618907)
"if pi is normal it's likely that each appears infinitely often."

Not likely, _certain_. If there is a sequence S that appears a finite number of times, there is a N such that as never appears after digit N. That, in turn, means that, in the limit of L => infinity, the probability that S appears in the first L digits is zero.

Re:Gzip + poetry = awesome by wging on Tuesday October 29, 2013 @12:35AM (#6632048)
Oh. Right. Whoops. Thanks.
Re:Gzip + poetry = awesome by weavie on Friday October 25, 2013 @04:00AM (#6610329)
Hmm.. it would also mean that somewhere in pi there is a sequence of 1 trillion consecutive zeros.
Re:Gzip + poetry = awesome by judk on Friday October 25, 2013 @11:46PM (#6616225)
Re:Gzip + poetry = awesome by dbaupp on Friday October 25, 2013 @02:55AM (#6610174)
If the conjecture of being normal is true, yes.
Re:Gzip + poetry = awesome by tehwalrus on Friday October 25, 2013 @03:11AM (#6610213)
however, we can write a non-infinite computer program that generates arbitrary digits of pi, meaning we can compress it infinitely better than the Shannon Entropy of the actual baseN representation - because it is a special case (most data can't be defined by a few words of mathematical definition).
Re:Gzip + poetry = awesome by danieldk on Friday October 25, 2013 @02:19AM (#6610079)
So if we just get the pointer of where that message is contained in the number and then calculate the number up to that pointer then we'll have ourselves the message.

As others have pointed out, the pointer would be longer than the original text in many cases.

It's very easy to express in layman's terms why perfect compression does not exist. If you had a compression algorithm that compressed every piece of data, it would introduce non-determinism. Say you had 4 bits (16 possibilities) and always compressed to fewer than 4 bits (8 possibilities), then one or more compressed datapoints would map to multiple uncompressed datapoints. Or in other words, you would lose information.

For a nice, format description, see Shannon's original paper:

http://plan9.bell-labs.com/cm/ms/what/shannonday/shannon1948...

Re:Gzip + poetry = awesome by willvarfar on Friday October 25, 2013 @01:28AM (#6609937)
There is a flaw in your random sequence approach; lets see if you can find it? Its a fun thinking exercise.

You can estimate the minimum bound on compression using Shannon's estimate http://en.wikipedia.org/wiki/Entropy_(information_theory)

An excellent problem for hobby coders is the Hutter Prize. Even if you don't win - and that'd be front page HN news if you did - its a really fun challenge and an excellent introduction to compression: http://prize.hutter1.net/

Also worth googling is Kolmogorov complexity.

Re:Gzip + poetry = awesome by tlarkworthy on Friday October 25, 2013 @04:20AM (#6610376)
Kolmogorov complexity captures your example. Kolmogorov complexity is the length of the shortest computer code that encodes a sequence. So the digits of Pi has a low computational complexity, because short programs exist that iteratively estimate PI. Random sequences have a high Kolmogorov complexity as their are no ways of generating the data.

Kolmogorov complexity measures the compressibility of a sequence. Its related to the information content, and is NP-Hard to compute!

The measure that takes into account the time to compute a sequence is the newer measure called "logical depth", but I only heard about that last week. The sequence of Ramsey numbers would have be very logically deep. A short program exists, but it takes forever to computer. The logical depth captures the amount of time you are saved by having the sequence precomputed.

Re:Gzip + poetry = awesome by rmc on Friday October 25, 2013 @05:08AM (#6610509)
It's impossible to have a lossless compression system that will always compress anything down to less size than it was originally, otherwise you could run it as many times as you want and compress everything down to 1 bit.

This includes "pointer to pi digits". What would probably happen there is the byte representation of the offset would be longer than the input string itself!

Although, now for curiousity, I'd like to actually try that "offset in pi" algorithm. :) Just for fun.

Re:Gzip + poetry = awesome by tjgq on Friday October 25, 2013 @05:17AM (#6610538)
Not to spoil your weekend project, but someone's done it already :)

https://github.com/philipl/pifs

Re:Gzip + poetry = awesome by ryanpetrich on Friday October 25, 2013 @01:27AM (#6609934)
It's possible that for many messages, the pointer of the message into the representation of pi may actually be larger than the message itself.
Re:Gzip + poetry = awesome by apw on Saturday October 26, 2013 @01:24AM (#6616468)
It would be better to say that this is a visualization of how a certain kind of dictionary compression works.

The outer limits of data compression lie in using predictive models plus arithmetic coders. A visualization of how they work might look very different.