Socket
Book a DemoInstallSign in
Socket

binary-shannon-entropy

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

binary-shannon-entropy

Calculate the shannon entropy of a buffer

latest
Source
npmnpm
Version
1.1.3
Version published
Weekly downloads
1.2K
69.19%
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 08 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts