title: Compressing a sparse bit array
body: <p>I have arrays of 1024 bytes (8192 bits) which are mostly zero.</p>
  
  <p>Between 0.01% and 10% of bits will be set (random, no pattern).</p>
  
  <p>How could these be compressed, given the lack of structure and the relatively small size?</p>
  
  <p>(My first thought was to store the distances between set bits.  I need 13 bits for each distance, but at worst case 10% occupancy this needs <code>13 * 816 / 8</code> = <code>1326</code> bytes, which is not an improvement.)</p>
  
  <p>This is for ultra-low bandwidth comms, so every byte matters.</p>