bse
binary-shannon-entropy
npm i binary-shannon-entropy
bse

binary-shannon-entropy

Calculate the Shannon entropy of a buffer

by Julian Gruber

1.1.3 (see all)License:MITTypeScript:Not Found
npm i binary-shannon-entropy
Readme

binary-shannon-entropy

Calculate the shannon entropy of a buffer.

build status

Example

var calc = require('binary-shannon-entropy');

calc(Buffer('aaaaa'));  // => 0
calc(Buffer('fffff'));  // => 0
calc(Buffer('aafaa'));  // => 0.7219280948873623
calc(Buffer('abcdef')); // => 2.584962500721156

Installation

$ npm install binary-shannon-entropy

API

calc(buf[, start][, end])

Return a number between 0 and 8, giving the Shannon entropy to the base of 2.

Optionally limit the area in the buffer to inspect by start and end.

Algorithm

H = -Sum(P_i * log2(P_i))

License

MIT

Downloads/wk

662

GitHub Stars

12

LAST COMMIT

7yrs ago

MAINTAINERS

1

CONTRIBUTORS

0

OPEN ISSUES

1

OPEN PRs

1
VersionTagPublished
1.1.3
latest
7yrs ago
No alternatives found
No tutorials found
Add a tutorial
No dependencies found

Rate & Review

100
No reviews found
Be the first to rate