Tool to calculate the Shannon index. The Shannon index is a measure of entropy for strings (or any computer data)

Shannon Index - dCode

Tag(s) : Informatics

dCode is free and its tools are a valuable help in games, puzzles and problems to solve every day!

You have a problem, an idea for a project, a specific need and dCode can not (yet) help you? You need custom development? *Contact-me*!

Sponsored ads

This script has been updated, please report any problems.

Tool to calculate the Shannon index. The Shannon index is a measure of entropy for strings (or any computer data)

Shannon's entropy index, as the name suggests, is a measure of the entropy that applies to any numerical data. It measures the frequencies of appearance of the characters, and the more they are different, the more difficult it will be to predict the content (thus a greater uncertainty, and thus a greater entropy).

For a string of characters with \( n \) distinct characters, each character having a frequency of \( p \). The entropy of Shannon \( H \) is calculated according to the formula $$ H = -\sum_{i=1}^n p_i \log_2 p_i \\ \approx $$

Example: DCODE has 5 characters including 4 distinct characters, the letter D appears 2 times (frequency: 2/5), and the 3 letters C, O and E each appear 1 time (frequency: 1/5), the calculation is: \( H = -\left( \frac{2}{5} \log_2{\frac{2}{5}} + 3 \times \frac{1}{5} \log_2{\frac{1}{5}} \right) \approx 1.921928 \)

From the Shannon index, the optimal encoding of a string can be deduced. If the Shannon index of a string is 3.5, then it will take 4 bits (rounded up) by characters to encode it optimally.

dCode retains ownership of the source code of the script Shannon Index online. Except explicit open source licence (indicated Creative Commons / free), any algorithm, applet, snippet, software (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, translator), or any function (convert, solve, decrypt, encrypt, decipher, cipher, decode, code, translate) written in any informatic langauge (PHP, Java, C#, Python, Javascript, etc.) which dCode owns rights can be transferred after sales quote. So if you need to download the online Shannon Index script for offline use, for you, your company or association, see you on contact page !

shannon,index,entropy,string,character,encoding,compression

Source : https://www.dcode.fr/shannon-index

© 2018 dCode — The ultimate 'toolkit' to solve every games / riddles / geocaches. dCode