News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Entropy

Started by 0x401000, October 19, 2009, 11:55:37 AM

Previous topic - Next topic

dsouza123

A test file  test1.exe  2560 bytes long was used to evaluate entropy.

A table with the count of occurences of each byte from test1.ex was constructed.

Fixed point with 32 . 32   dword integer part and dword fractional part was used to store the numbers.

The log 2 function was only exact if the number was a power of 2 with no fraction  example 128.
A number such as 160  was broken down to  log 2 of 128  plus  log 2  (1.25) from a 16 entry lookup table,
so the values are approximate.   1.25  is  160/128     
log 2 ( 128 * 1.25) ->   log 2 ( 2^7 * 1.25)  ->  log 2 ( 2^7) + log 2 (1.25) -> 7 log 2 ( 2 ) + log 2 ( 1.25 ) -> 7  + log 2 ( 1.25 )

There is a formula using continued fractions that will directly calculate the ln ( log e, natural logarithm ) of a number.
First the value's range is brought down below e  using something similar to the preceding transformation.
Then  ln(value) / ln(2) will transform it to a base 2 logarithm.  This formula wasn't used.

The proper base for an 8 bit item is base 256 so using base 2 gives a range 0.0 to 8.0 
scaling by 1/8 corrects it to 0.0 to 1.0

If the items were 1 bit then base 2 would be appropriate.

0x401000

Wow, joy has no limits, thanks!  :U