In message <[EMAIL PROTECTED]>, Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Steven D'Aprano > wrote: > >> On Sat, 18 Oct 2008 09:16:11 +1300, Lawrence D'Oliveiro wrote: >> >>> Data can come in fractional bits. That's how compression works. >> >> If you don't believe me, try compressing a single bit and see if you get >> a "fractional bit". > > If both states of the bit are not equally likely, then you do indeed have > a fractional bit, since > > nrbits = (- logbase2(P[bit = 0]) - logbase2(P[bit = 1])) / 2
Oops, sorry, the formula should of course be nrbits = - P[bit = 0] * logbase2(P[bit = 0]) - P[bit = 1] * logbase2(P[bit = 1]) -- http://mail.python.org/mailman/listinfo/python-list