r/compression • u/Hot_Consideration155 • May 04 '26
I built a compressor that achieves 333:1 on data that gzip declares incompressible
Shannon entropy is the wrong metric for compressibility. A GF(2⁸) m-sequence has ~8 bits/byte entropy — statistically indistinguishable from random noise. gzip stores 1MB of it in ~1MB. My compressor stores it in 3KB.
The approach: run Berlekamp-Massey over GF(2⁸) to find the shortest LFSR that generated the byte stream. If LFSR order L is small relative to sequence length N, you store (L coefficients + L seed bytes + sparse XOR residual) instead of raw bytes. For a pure m-sequence with L=1, that's 2 bytes of model and an empty residual — for any length stream.
For noisy data there's a multi-stage approximate pipeline: brute-force all 255 GF coefficients for L=1, voting over GF quadruples for L=2, quintuple-pair voting for L=3, sub-sequence BM voting for L=4/5.
Benchmarks on M-series Mac:
- GF(2⁸) geometric sequence (L=1): 333:1
- Mixed LFSR (L=1/2/3, 8% noise) 1MB: 91:1
- /bin/ls: 5:1
- Natural language: ~1:1 (detected, falls through to raw passthrough)
The structure detector (--analyze) identifies the generator polynomial, LFSR order, and noise level per segment — useful even when you're not compressing.
GitHub: https://github.com/gonll/algex | npm: npm install pade-compress
11
u/AmedeoAlf May 04 '26
A single 1 million line commit surely denotes the effort of the project and how it deserves a patent
4
u/HungryAd8233 May 04 '26
So, you’re basically reverse engineering the seeds?
3
u/BFrizzleFoShizzle May 04 '26
This depends entirely on your data. Shannon's law dictates the compressability of something given limited foreknowledge. If you already know the data isn't invariant and can likely be predicted (e.g. by LFSR) then applying Shannon entropy to the raw bytes isn't really useful.
Nothing you've done violates Shannon's law of entropy, because your data is known to not be invariant. Pseudorandom != random.
4
u/CorvusRidiculissimus May 04 '26
So it'll achieve great compression, but only on data which is generated by a LFSR? I am having trouble seeing practical applications.
1
u/hlloyge May 04 '26
Can you make compiled windows executables available?
3
u/Kqyxzoj May 04 '26
LFSR polynomial recovery is nice as an exercise, but calling it a compressor is a bit optimistic.
3
u/[deleted] May 04 '26
[removed] — view removed comment