Surprise Calculator!

This widget calculates the information content (also called surprise) for each symbol/token/character in a given message.

The calculations assume that the alphabet used to encode the message is only made up of the symbols/characters present in the message.


Input

Output

The outputs include a table showing the number of bits required to encode a character in the alphabet, and a heatmap of the message.
Red characters have the most information content.
Lighter/pale characters have less information content.
White characters have 0 information content; although you will never see a character with 0 bits of information.
You can hover over each character in the heatmap to see its information content.

P(x) is the probability that a token/character occurs in the message. Its value ranges from 0 (exclusive) to 1 (inclusive).

I(x) is the information content/surprise that a token/character carries in the message. Its value is measured in bits and is always greater than zero.

Alphabet Size:
Symbol (x)P(x)I(x) bits