Let me make up an example that illustrates the idea behind Shannon's definition of information.
Suppose you have four possible messages that might come from your daughter away in college:
- Everything's fine.
- Send more money.
- I had to skip class because I'm sick.
- I met a cute boy in class
Let's suppose that half of her messages are #1, one-fourth are #2, and one-eighth are #3 and one-eighth are #4.
Now, suppose she wants to send her messages in code: just dots and dashes (she got the cheapest phone plan, which only allows communication in Morse code). What is the most efficient way for her to send you a message?
Obviously, she could use Morse code, which gives dots and dashes for every letter of the alphabet. On the average, that would mean maybe six signals per letter, or about 600 or so for the whole message. That's obviously an inefficient way to do it, if she only ever sends 4 messages. A better way would be:
dot = message 1
dash dot = message 2
dash dash dot = message 3
dash dash dash = message 4
On the average, the number of signals per message would then be computed as follows:
- Half the time, she just needs 1 signal, a dot.
- 1/4 the time, she needs 2 signals, a dash dot.
- 1/8 the time, she needs 3 signals, a dash dash dot or dash dash dash.
On the average, it takes 7/4 signals per message. That's the best she can possibly do. Any other way of coding her messages as dots and dashes would, on the average, require more signals per message.
So we can define the "average information content" of her messages to be 1.75 bits.
In the general case, the best we can do in coding messages as bits (or dots and dashes) is given by:
##S \geq \sum_j p_j log(\frac{1}{p_j})##
where ##p_j## is the probability of message number ##j##, and ##log## means logarithm, base 2, and where ##S## is the average number of bits required to convey a message. The best possible code uses a number of bits that is equal to the log of the reciprocal of the probability of a message. (Of course, this number might not be an integer, so you have to round up. That's why you get ##\geq## instead of ##=##.)