dsize; // size of original data buffer wsize; // size of sliding window inbuff[dsize]; // original data outbuff[dsize-wsize]; // entropy calculations counts[256]; // a running count of the number of each type // of byte currently visible in the sliding window // produce an initial count of each unique byte currently // visible in the sliding window, place values in counts[], // all other indexes should be zeroed. // calculate entropy for initial window position for (i = 0; i < 256; i++) outbuff[0] -= counts[i]/wsize * log(2, counts[i]/wsize); // slide window and iteratively update entropy calculation for (i = 1; i < dsize-wsize; i++) { t1 = counts[inbuff[i-1]]/wsize; t2 = counts[inbuff[i+wsize-1]]/wsize; outbuff[i] = outbuff[i-1] + t1 * log(2, t1) + t2 * log(2,t2); // update counts[] t1 = counts[inbuff[i-1]]/wsize; t2 = counts[inbuff[i+wsize-1]]/wsize; outbuff[i] -= t1 * log(2, t1) + t2 * log(2,t2); }
There are 31,313 total registered users.
[+] expand