Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'algorithm': 0.04; 'reason,': 0.07; 'suppose': 0.07; 'method,': 0.09; 'cc:addr :python-list': 0.11; 'anyway': 0.14; '"0"': 0.16; "'cause": 0.16; 'compression': 0.16; 'obviously,': 0.16; 'outputs': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'sat,': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'items.': 0.19; 'fit': 0.20; '>>>': 0.22; 'input': 0.22; 'cc:addr:python.org': 0.22; 'byte': 0.24; 'expanded': 0.24; 'cc:2**0': 0.24; 'second': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; "doesn't": 0.30; 'sets': 0.30; 'message-id:@mail.gmail.com': 0.30; 'too.': 0.31; '-0700,': 0.31; "d'aprano": 0.31; 'piece': 0.31; 'steven': 0.31; 'subject:that': 0.31; 'lists': 0.32; 'totally': 0.33; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'data,': 0.36; 'sequence': 0.36; 'two': 0.37; 'list': 0.37; 'sometimes': 0.38; 'nov': 0.38; 'rather': 0.38; 'does': 0.39; 'structure': 0.39; 'how': 0.40; 'then,': 0.60; 'length': 0.61; 'matter': 0.61; 'you.': 0.62; 'email addr:gmail.com': 0.63; 'more': 0.64; 'different': 0.65; 'news': 0.67; 'containing': 0.69; 'bag,': 0.84; 'demonstrates': 0.84; 'holes': 0.84; 'careful': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=jEeIKITKhL12+yKuuRYa82NX9lJFzQ8cN5MRXxbYOdE=; b=AM66T0NLIkvqNv8UKtVpevDqYGl9YHnUpXzx5waSZ4DQ9SaLejvpIackswt67cTS/4 9AQmBF+k+EfnQ5GVmbMGPIx8g1cUrLGiPgagLDSx/cnnXESJ8p3PqrDY7LWM0YnJbvpJ eflmqo9jL7kxBFrmdTyk3RnYNjuysxxNG53vaxoWZ7UsCkogc925LK3UQhukpXMDQaY2 cRCS+EdLL+Yt0qsoOsee1rT5YfVGHNdDrSmqM5sM6+Fohf5fnFPIYwUO/6ajvvbd7Ili wgZj5DokgLeeBdIvOOWoWZD9s8bwQzhqPEIRzcr5XCgUaQ+MS6hhakxaAxZsfeseclnA Rvog== X-Received: by 10.152.22.198 with SMTP id g6mr8557266laf.5.1383492887707; Sun, 03 Nov 2013 07:34:47 -0800 (PST) MIME-Version: 1.0 Sender: joshua.landau.ws@gmail.com In-Reply-To: <5275c065$0$29972$c3e8da3$5496439d@news.astraweb.com> References: <205bfa4f-29de-43de-be5a-72a12d77d0c9@googlegroups.com> <5275c065$0$29972$c3e8da3$5496439d@news.astraweb.com> From: Joshua Landau Date: Sun, 3 Nov 2013 15:34:07 +0000 X-Google-Sender-Auth: T7hpX3YPHTDMMeeSKv94rm6Y6uY Subject: Re: Algorithm that makes maximum compression of completly diffused data. To: "Steven D'Aprano" Content-Type: text/plain; charset=UTF-8 Cc: python-list X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1383492895 news.xs4all.nl 15977 [2001:888:2000:d::a6]:46638 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:58399 On 3 November 2013 03:17, Steven D'Aprano wrote: > On Sat, 02 Nov 2013 14:31:09 -0700, Tim Roberts wrote: > >> jonas.thornvall@gmail.com wrote: >>> >>>Well then i have news for you. >> >> Well, then, why don't you share it? >> >> Let me try to get you to understand WHY what you say is impossible. > [snip reasons] > > But your second reason, better known as the pigeonhole principle, > demonstrates that for any lossless compression method, there must be data > sets that actually expand the data. It doesn't matter how cleverly you > compress the data, you can't fit 20kg of potatoes in a 10kg bag, so to > speak. Suppose your compression algorithm compresses a single byte into a > nybble (four bits). There are 256 different input data sets (0x00, > 0x01, ... 0xFF) and only 16 different outputs (0x0, 0x1, ... 0xF). There > is no way for 256 pigeons to fit in 16 pigeon holes unless you put two or > more pigeons in at least one hole. Ergo, if the compression algorithm is > lossless, *some* data must be expanded rather than compressed. You have to be careful to make this totally rigorous, too. Note that I *can* make a "compression" algorithm that takes any length-n sequence and compresses all but one sequence by at least one bit, and does not ever expand the data. "00" -> "" "01" -> "0" "10" -> "1" "11" -> "00" This, obviously, is just 'cause the length is an extra piece of data, but sometimes you have to store that anyway ;). So if I have a list of N length-Y lists containing only 1s or 0s, I can genuinely compress the whole structure by N log2 Y items.