diff --git a/README.md b/README.md index 838f008..73d696d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Written in Python, this calculates the information entropy and maximum entropy of a given string or file. -## How does this work? +## How does it work? 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. @@ -12,11 +12,12 @@ Mathematically speaking this is `-sum(p*log(p))` with p being the probability of Well that is basically up to you. Entropy functions are used in Computer Science mainly for calculation of compression potential or in cryptography. But you are free to use this for whatever you want. I wrote it as preparation for one of my exams. -*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. +*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 throws etc. 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 (you can skip the quotation marks if you don't have spaces in your string - if you want): ``` @@ -43,6 +44,7 @@ entro.py "teststring" "teststring2" teststring3 -files test1.txt -files test2.tx ## Command line parameters ### Output Adjustments + `--simple` determines whether the output is explicit like this: ``` @@ -73,6 +75,7 @@ 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)