NNTP-Posting-Date: Sat, 03 Apr 2010 18:04:43 -0500
Date: Sat, 03 Apr 2010 16:05:36 -0700
From: Tim Wescott <>
User-Agent: Thunderbird (X11/20100317)
MIME-Version: 1.0
Newsgroups: comp.soft-sys.matlab,comp.dsp
Subject: Re: How do I compress an array of floating numbers in Matlab?
References: <>
In-Reply-To: <>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <>
Lines: 36
X-Trace: sv3-vhsuScgJEIzYIP91fagynmbCCKlWgOwxYyWAzGKdF7KsfIFTYIOTkIPMkDpTxPrcK+7QtXFub5XskJi!+VSzt0ZahDoJaUcg5Q1wIoMKF3KMHcHnvWnBxp+SeBxqV1s++wI+zkQkBbWb/tmQyk8NwKZZ4vaN!AjPhpY6Tr5sDN2Y=
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
Xref: comp.soft-sys.matlab:623220 comp.dsp:269977

Luna Moon wrote:
> Hi all,
> I have a vector of real numbers in Matlab. How do I compress them?  Of
> course this has to be lossless, since I need to be able to recover
> them.
> The goal is to study the Shannon rate and entropy of these real
> numbers, so I decide to compress them and see how much compression
> ratio I can have.
> I don't need to write the result into compressed files, so those
> headers, etc. are just overhead for me which affect me calculating the
> Entropy... so I just need a bare version of the compress ratio...
> Any pointers?

Find another approach to getting an answer, maybe.

First, most lossless compression algorithms are designed for things like 
text, executables, and data bases -- they don't do well with floating 
point numbers, tending to see them as "random" even when they're not.

Second, if you measure a bunch of meaningless white noise and put the 
result into floating point numbers, then put them into a lossless 
algorithm that _can_ handle floating point, it's not going to compress 
at all, because the algorithm can't distinguish between white noise and 
a signal that's chock-full of information.  In effect you'll have 
_given_ it a signal full of information, in great detail, about the noise.

I think you're leading yourself down the garden path.

Tim Wescott
Control system and signal processing consulting