# How realistic is the i.i.d assumption in the definition of Shannon's entropy?

Let me first say I come from a physics background and have about zero exposure to computer science, so the question may be very naive. Shannon's entropy looks perfectly natural and useful from a statistical/thermal physics point of view, but now I'm trying to understand how it is applied for real computers.

Normally the messages we want to store and process in a computer have grammar and meanings, which seems to suggest the symbols constituting the message must follow some conditional probability distribution, and the utterance of the symbol at the nth position should change the probability distribution of the symbol that will appear at the (n+1)-th position. However, in Shannon's definition symbols are assumed to be independent and identically distributed random variables, which seems to be far from realistic, so how come it is still a useful concept for computers?

• Where is this assumption made? As far as I know, independence isn't assumed for entropy in information theory, we even have the case of conditional Shannon entropy, which would be useless to define if independence was an assumption. Can you state the definition here and where you found it? – Discrete lizard Apr 15 '18 at 21:20
• @Discretelizard,for example I'm looking at this definition: en.wikipedia.org/wiki/Entropy_(information_theory)#Definition. Here it uses a single random variable $X$, but if one takes each position of a string of symbols to be a random variable, then this is the same as saying these random variables are i.i.d. – Jia Yiyang Apr 16 '18 at 0:25
• Your conclusion that the individual symbols must be iid does not follow, as D.W. states. If you wish to know why this is the case, please edit your question with your reasoning why you think these symbols must be iid. – Discrete lizard Apr 16 '18 at 9:54

There is a special case when the symbols are iid random variables, and you might have seen a formula for that special case (which is indeed simpler), but the definition is fully general. Note that when we write the entropy $H(X)$, you should take the random variable $X$ to be the entire sequence of symbols. Then the standard definition applies directly, and doesn't assume that each individual symbol in $X$ is iid.
• I see,, +1, in physics language I misunderstood "ensembles" as "levels". This brings me the next question, in a real computer, when I see a file has size say 5MB, exactly what is the random variable $X$? It probably depends on the type of the file? For txt files, since I heard each letter is assigned a fixed amount of bits, it probably means the random variable in this case is just single letters. – Jia Yiyang Apr 16 '18 at 16:28
• @JiaYiyang, asking about the (Shannon) entropy of a file does not make sense and is not well-defined. What is well-defined is the entropy of a random process. The random process defines a random variable $X$ (a distribution), and then you can calculate the (Shannon) entropy of that random variable. So if you told me "I have a process for generating a random file; what is the entropy of that process?", that would be an answerable question. If you tell me "I have a file, what is the (Shannon) entropy of that file?", that's not answerable, as the notion isn't even well-defined. – D.W. Apr 16 '18 at 16:53