On Feb 11, 3:10 pm, Robert Wessel <
robertwess...@yahoo.com> wrote:
> On Sat, 11 Feb 2012 09:10:45 -0800 (PST), Industrial One
>
actually if you have N objects and N = 2**X you need exactly X bits
if its not a power of 2 find 2**X that is the next power of 2.
get Y = 2(N - 2**(X-1) )
assign Y symbols to X bits and (N-Y) to X-1 bits then you mantain
the integer number of bit for each symbol
examples symbols A B C D since 2**2 = 4 each two bits
A = 00
B = 01
C = 10
D = 11
next symbols 5 of them A B C D E X=3 X-1 = 2
Y=2(5 -4)=2 so 2 3bits 3 2 bits since 5-2 = 3
A = 00
B = 01
C = 10
D = 110
E = 111
next symbols 6 of them A B C D E F X=3 X-1 = 2
Y=2(6 -4)=4 so 4 3bits 2 2 bits since 6-4 = 2
A = 00
B = 01
C = 100
D = 101
E = 110
F = 111
next symbols 7 of them A B C D E F G X=3 X-1 = 2
Y=2(7 -4)=6 so 6 3bits 1 2 bits since 7-6 = 1
A = 00
B = 010
C = 011
D = 100
E = 101
F = 110
G = 111
Take this last case and assume A through F random
then if each symbol appeared once you need 20 bits for
7 characters that is 2.85714286 per character
if you used arithmetic ln(7)/ln(2) 2.80735492 per character
so in this case arithmetic would be better.
David A. Scott
--
My Crypto code
http://bijective.dogma.net/crypto/scott19u.zip
http://www.jim.com/jamesd/Kong/scott19u.zip old version
My Compression code
http://bijective.dogma.net/
**TO EMAIL ME drop the roman "five" **
Disclaimer:I am in no way responsible for any of the statements
made in the above text. For all I know I might be drugged.
As a famous person once said "any cryptograhic
system is only as strong as its weakest link"