jeudi 7 mai 2015

Why does liblzma fail to compress any random string?

I'm using the ruby binding, ruby-xz.

random_string = SecureRandom.random_bytes(100)
compressed_string = XZ.compress(random_string, compression_level = 9, check = :none, extreme = true)
compressed_string.size # => always 148

I've tested it ten thousands of times, on strings of varying length.

I know that at least half of the strings are 1-incompressible (cannot be compresse by more than 1 bit), 3/4 of the strings are 2-incompressible, etc. (This follows from a counting argument.) This, obviously, says nothing about the lower bound of the number compressible strings, but there are bound to be a few, aren't there?




Aucun commentaire:

Enregistrer un commentaire