Re: what kind of compressor is best for...



jules Gilbert wrote:

Let me pose this problem and see if you can help me,

First, let me described the data. You can build this small test env.

char buf[MEG];

void
build_buffer()
{
int r1 = random() & 255;
int r2 = random() & 255;
int rr = r1 & r2;

buf[ptr++] = rr;
}

Given that random() delivers samples from a uniform i.i.d. random source, then bits in r1 & r2 (binary-and) have indeed probabilities 1/4 and 3/4. As symbol probabilities are not exact powers of two, Huffman coding is not directly applicable. Instead, you need arithmetic coding here for optimal results. Non-adaptive coding is sufficient here as the source is stationary. Don't do bzip2, you're just adding overhead for a source as simple as this.

As a side remark, random() is most likely a pseudo-random generator based on linear congruence. In this case, using masks to extract the lower bits generates pretty poor generators with a period of at most 256 (in your case), and thus not a very random source. Rather, try to use the upper bits instead.

So long,
Thomas
.



Relevant Pages

  • Virtual/Non-Virtual + different signature
    ... virtual void VirtualMethod; ... void NonVirtualMethod(int a, char c); ... Is it good coding to have different signatures for a non-virtual methods ...
    (comp.lang.cpp)
  • Your opinion on my VC++ application
    ... for foundation design. ... Actually firstly what I did is I kept my all c coding in CACIDlg.cpp ... void CACIDlg::addstring ...
    (microsoft.public.vc.language)
  • Re: Which is the better method to use "if else" statements
    ... Vladimir Vassilevsky wrote: ... My coding standards are titled "Coding GUIDELINES". ... while (FOREVER) { ...
    (comp.arch.embedded)
  • Re: Encoder programming
    ... designing a motor controller circuit using pic 16f877a. ... Iv finished the coding for the motor controller part ... NowI dont know how to do the programming for this encoder. ... void m1 ...
    (comp.arch.embedded)
  • Encoder programming
    ... designing a motor controller circuit using pic 16f877a. ... Iv finished the coding for the motor controller part ... NowI dont know how to do the programming for this encoder. ... void m1 ...
    (comp.arch.embedded)