From 0d623b4b31c8e60135235a3f8515341250b995c6 Mon Sep 17 00:00:00 2001 From: Conrad Date: Thu, 18 Jul 2019 14:05:51 +0200 Subject: [PATCH] Update README.md --- README.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2eb7bd4..2e0df0d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Written in Python, this calculates the information entropy of a given string or This is a pretty simple calculator which just uses the negative sum of all the probabilities of the chars in a given string multiplied with the logarithm to the base two of the probabilities. The probabilities of the chars are calculated simply by counting the occurrence divided by the total number of chars. -Mathematically speaking this is -sum(p*log(p)) with p being the probability of a char occurring. +Mathematically speaking this is -sum(p*log(p)) with p being the probability of a char occurring. The maximum entropy calculation is explained below. ## What is it good for? @@ -14,8 +14,11 @@ Well that is basically up to you. Entropy functions are used in Computer Science *Warning:* This can only be used for calculating the entropy of strings (by alphabet). There are however other types like coin tosses of fair or unfair coins (...), but you're gonna have to write calculators for this on your own - for now. +*Update:* This script now can calculate the maximum entropy now too. This is pretty useful for pre-compression analyses. Maximum entropy is calculated by splitting the alphabet into parts of the same size and calculating the entropy of this, like: -1 * SIZE_OF_ALPHABET * (DISTINCT_PROBABILITY * log(DISTINCT_PROBABILITY, 2)). + ## Usage You can run as much calculations as you want in one run of the script. For example use it like this with a simple string: + ``` entro.py teststring ``` @@ -58,7 +61,18 @@ Entropy: 1.5 bits --- ``` -### String conversion +`--max` determines whether the output includes the maximum entropy or not, still will show if `--simple` is set: + +``` +--- +Content: TEST +Probabilities: {'T': 0.5, 'E': 0.25, 'S': 0.25} +Entropy: 1.5 bits +Maximum Entropy: 1.584962500721156 bits +--- +``` + +### String Conversion `--lower` - Converts the input strings to lowercase `--upper` - Opposite of lower, converts to upper (if both are set only lower will be executed)