Misplaced Pages

Entropy (information theory): Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Browse history interactively← Previous editContent deleted Content addedVisualWikitext
Revision as of 21:27, 5 September 2006 edit208.255.152.227 (talk) Derivation of Shannon's entropy← Previous edit Latest revision as of 23:56, 5 December 2024 edit undoIznoRepeat (talk | contribs)Extended confirmed users50,076 editsm add WP:TEMPLATECAT to remove from template; genfixesTag: AWB 
Line 1: Line 1:
{{short description|Expected amount of information needed to specify the output of a stochastic data source}}
] as a function of success probability, often called the ''']'''.]]
{{other uses|Entropy (disambiguation)}}
{{More citations needed|date=February 2019}}
{{Use dmy dates|date=October 2023}}
{{Use American English|date=December 2024}}


{{Information theory}}
'''Entropy''' is a concept in ] (see ]), ] and ]. The concepts of information and entropy have deep links with one another, although it took many years for the development of the theories of statistical mechanics and information theory to make this apparent. This article is about '''information entropy''', the information-theoretic formulation of ]. Information entropy is occasionally called '''Shannon's entropy''' in honor of ], who formulated many of the key ideas of information theory.


In ], the '''entropy''' of a ] quantifies the average level of uncertainty or information associated with the variable's potential states or possible outcomes. This measures the expected amount of information needed to describe the state of the variable, considering the distribution of probabilities across all potential states. Given a discrete random variable <math>X</math>, which takes values in the set <math>\mathcal{X}</math> and is distributed according to <math>p\colon \mathcal{X}\to</math>, the entropy is
==Introduction==
<math display="block">\Eta(X) := -\sum_{x \in \mathcal{X}} p(x) \log p(x),</math>
where <math>\Sigma</math> denotes the sum over the variable's possible values.<ref group=Note name=Note01/> The choice of base for <math>\log</math>, the ], varies for different applications. Base 2 gives the unit of ]s (or "]s"), while base ] gives "natural units" ], and base 10 gives units of "dits", "bans", or "]". An equivalent definition of entropy is the ] of the ] of a variable.<ref name="pathriaBook">{{cite book|last1=Pathria|first1=R. K.|url=https://books.google.com/books?id=KdbJJAXQ-RsC|title=Statistical Mechanics|last2=Beale|first2=Paul|date=2011|publisher=Academic Press|isbn=978-0123821881|edition=Third|page=51}}</ref>


]
The concept of entropy in ] describes how much information there is in a signal or event. Shannon introduced the idea of information entropy in his ] paper "".


The concept of information entropy was introduced by ] in his 1948 paper "]",<ref name="shannonPaper1">{{cite journal|last=Shannon|first=Claude E.|author-link=Claude Shannon|date=July 1948|title=A Mathematical Theory of Communication|journal=]|volume=27|issue=3|pages=379–423|doi=10.1002/j.1538-7305.1948.tb01338.x|hdl-access=free|title-link=A Mathematical Theory of Communication|hdl=10338.dmlcz/101429}} (, archived from {{Webarchive|url=https://web.archive.org/web/20140620153353/http://www3.alcatel-lucent.com/bstj/vol27-1948/articles/bstj27-3-379.pdf |date=20 June 2014 }})</ref><ref name="shannonPaper2">{{cite journal|last=Shannon|first=Claude E.|author-link=Claude Shannon|date=October 1948|title=A Mathematical Theory of Communication|journal=]|volume=27|issue=4|pages=623–656|doi=10.1002/j.1538-7305.1948.tb00917.x|hdl-access=free|title-link=A Mathematical Theory of Communication|hdl=11858/00-001M-0000-002C-4317-B}} (, archived from {{Webarchive|url=https://web.archive.org/web/20130510074504/http://www.alcatel-lucent.com/bstj/vol27-1948/articles/bstj27-4-623.pdf |date=10 May 2013 }})</ref> and is also referred to as '''Shannon entropy'''. Shannon's theory defines a ] system composed of three elements: a source of data, a ], and a receiver. The "fundamental problem of communication" – as expressed by Shannon – is for the receiver to be able to identify what data was generated by the source, based on the signal it receives through the channel.<ref name="shannonPaper1" /><ref name="shannonPaper2" /> Shannon considered various ways to encode, compress, and transmit messages from a data source, and proved in his ] that the entropy represents an absolute mathematical limit on how well data from the source can be ]ly compressed onto a perfectly noiseless channel. Shannon strengthened this result considerably for noisy channels in his ].
An intuitive understanding of information entropy relates to the amount of ''uncertainty'' about an event associated with a given ]. As an example, consider a box containing many coloured balls. If the balls are all of different colours and no colour predominates, then our uncertainty about the colour of a randomly drawn ball is maximal. On the other hand, if the box contains more red balls than any other colour, then there is slightly less uncertainty about the result: the ball drawn from the box has more chances of being red (if we were forced to place a bet, we would bet on a red ball). Telling someone the colour of every new drawn ball provides them with more information in the first case than it does in the second case, because there is more uncertainty about what might happen in the first case than there is in the second. Intuitively, if there were no uncertainty as to the outcome, then we would learn nothing by drawing the next ball, and so the information content would be zero. As a result, the entropy of the "signal" (the sequence of balls drawn, as calculated from the probability distribution) is higher in the first case than in the second.


Entropy in information theory is directly analogous to the ] in ]. The analogy results when the values of the random variable designate energies of microstates, so Gibbs's formula for the entropy is formally identical to Shannon's formula. Entropy has relevance to other areas of mathematics such as ] and ]. The definition can be derived from a set of ]s establishing that entropy should be a measure of how informative the average outcome of a variable is. For a continuous random variable, ] is analogous to entropy. The definition <math>\mathbb{E} </math> generalizes the above.
Shannon, in fact, defined entropy as a measure of the average information content associated with a random outcome.


==Introduction==
Shannon's definition of information entropy makes this intuitive distinction mathematically precise. His definition satisfies these desiderata:
The core idea of information theory is that the "informational value" of a communicated message depends on the degree to which the content of the message is surprising. If a highly likely event occurs, the message carries very little information. On the other hand, if a highly unlikely event occurs, the message is much more informative. For instance, the knowledge that some particular number ''will not'' be the winning number of a lottery provides very little information, because any particular chosen number will almost certainly not win. However, knowledge that a particular number ''will'' win a lottery has high informational value because it communicates the occurrence of a very low probability event.


The ''],'' also called the ''surprisal'' or ''self-information,'' of an event <math>E</math> is a function that increases as the probability <math>p(E)</math> of an event decreases. When <math>p(E)</math> is close to 1, the surprisal of the event is low, but if <math>p(E)</math> is close to 0, the surprisal of the event is high. This relationship is described by the function
* The measure should be continuous &mdash; i.e., changing the value of one of the probabilities by a very small amount should only change the entropy by a small amount.
<math display="block">\log\left(\frac{1}{p(E)}\right) ,</math>
* If all the outcomes (ball colours in the example above) are equally likely, then entropy should be maximal.
where <math>\log</math> is the ], which gives 0 surprise when the probability of the event is 1.<ref>{{cite web |url = https://www.youtube.com/watch?v=YtebGVx-Fxw |title = Entropy (for data science) Clearly Explained!!! |date = 24 August 2021 |via = ] |access-date = 5 October 2021 |archive-date = 5 October 2021 |archive-url = https://web.archive.org/web/20211005135139/https://www.youtube.com/watch?v=YtebGVx-Fxw |url-status = live }}</ref> In fact, {{math|log}} is the only function that satisfies а specific set of conditions defined in section ''{{slink|#Characterization}}''.
* If the outcome is a certainty, then the entropy should be zero.
* The amount of entropy should be the same independently of how the process is regarded as being divided into parts.


Hence, we can define the information, or surprisal, of an event <math>E</math> by
(Note: The Shannon/Weaver book makes reference to ] (]) who in turn credits ] (]) with the definition of entropy Shannon used. Elsewhere in statistical mechanics, the literature includes references to ] having derived the same form of entropy in ], which may explain why von Neumann favoured the use of the existing term 'entropy'.)
<math display="block">I(E) = -\log_2(p(E)) ,</math>
or equivalently,
<math display="block">I(E) = \log_2\left(\frac{1}{p(E)}\right) .</math>


Entropy measures the expected (i.e., average) amount of information conveyed by identifying the outcome of a random trial.<ref name="mackay2003">{{cite book|last=MacKay|first=David J.C.|author-link=David J. C. MacKay|url=http://www.inference.phy.cam.ac.uk/mackay/itila/book.html|title=Information Theory, Inference, and Learning Algorithms|publisher=Cambridge University Press|year=2003|isbn=0-521-64298-1|access-date=9 June 2014|archive-date=17 February 2016|archive-url=https://web.archive.org/web/20160217105359/http://www.inference.phy.cam.ac.uk/mackay/itila/book.html|url-status=live}}</ref>{{rp|67}} This implies that rolling a die has higher entropy than tossing a coin because each outcome of a die toss has smaller probability (<math>p=1/6</math>) than each outcome of a coin toss (<math>p=1/2</math>).
==Formal definitions==


Consider a coin with probability {{math|''p''}} of landing on heads and probability {{math|1 − ''p''}} of landing on tails. The maximum surprise is when {{math|''p'' {{=}} 1/2}}, for which one outcome is not expected over the other. In this case a coin flip has an entropy of one ]. (Similarly, one ] with equiprobable values contains <math>\log_2 3</math> (about 1.58496) bits of information because it can have one of three values.) The minimum surprise is when {{math|''p'' {{=}} 0}} or {{math|''p'' {{=}} 1}}, when the event outcome is known ahead of time, and the entropy is zero bits. When the entropy is zero bits, this is sometimes referred to as unity, where there is no uncertainty at all – no freedom of choice – no ]. Other values of ''p'' give entropies between zero and one bits.
Shannon defines entropy in terms of a discrete random event ''x'', with possible states (or outcomes) 1...''n'' as:


=== Example ===
:<math>H(x)=\sum_{i=1}^np(i)\log_2 \left(\frac{1}{p(i)}\right)=-\sum_{i=1}^np(i)\log_2 p(i).\,\!</math>
Information theory is useful to calculate the smallest amount of information required to convey a message, as in ]. For example, consider the transmission of sequences comprising the 4 characters 'A', 'B', 'C', and 'D' over a binary channel. If all 4 letters are equally likely (25%), one cannot do better than using two bits to encode each letter. 'A' might code as '00', 'B' as '01', 'C' as '10', and 'D' as '11'. However, if the probabilities of each letter are unequal, say 'A' occurs with 70% probability, 'B' with 26%, and 'C' and 'D' with 2% each, one could assign variable length codes. In this case, 'A' would be coded as '0', 'B' as '10', 'C' as '110', and 'D' as '111'. With this representation, 70% of the time only one bit needs to be sent, 26% of the time two bits, and only 4% of the time 3 bits. On average, fewer than 2 bits are required since the entropy is lower (owing to the high prevalence of 'A' followed by 'B' – together 96% of characters). The calculation of the sum of probability-weighted log probabilities measures and captures this effect.


English text, treated as a string of characters, has fairly low entropy; i.e. it is fairly predictable. We can be fairly certain that, for example, 'e' will be far more common than 'z', that the combination 'qu' will be much more common than any other combination with a 'q' in it, and that the combination 'th' will be more common than 'z', 'q', or 'qu'. After the first few letters one can often guess the rest of the word. English text has between 0.6 and 1.3 bits of entropy per character of the message.<ref name="Schneier, B page 234">Schneier, B: ''Applied Cryptography'', Second edition, John Wiley and Sons.</ref>{{rp|234}}
That is, the entropy of the event ''x'' is the sum, over all possible outcomes ''i'' of ''x'', of the product of the probability of outcome ''i'' times the log of the inverse of the probability of ''i'' (which is also called ''i'''s '']'' - the entropy of ''x'' is the expected value of its outcome's surprisal). We can also apply this to a general ], rather than a discrete-valued event.


==Definition==
Shannon shows that any definition of entropy satisfying his assumptions will be of the form:
Named after ], Shannon defined the entropy {{math|&Eta;}} (Greek capital letter ]) of a ] <math display="inline">X</math>, which takes values in the set <math>\mathcal{X}</math> and is distributed according to <math>p: \mathcal{X} \to </math> such that <math>p(x) := \mathbb{P}</math>:


::<math>-K\sum_{i=1}^np(i)\log p(i).\,\!</math> <math display="block">\Eta(X) = \mathbb{E} = \mathbb{E}.</math>


Here <math>\mathbb{E}</math> is the ], and {{math|I}} is the ] of {{math|''X''}}.<ref>{{cite book|author=Borda, Monica|title=Fundamentals in Information Theory and Coding|publisher=Springer|year=2011|isbn=978-3-642-20346-6|url=https://books.google.com/books?id=Lyte2yl1SPAC&pg=PA11}}</ref>{{rp|11}}<ref>{{cite book|author1=Han, Te Sun |author2=Kobayashi, Kingo |title=Mathematics of Information and Coding|publisher=American Mathematical Society|year=2002|isbn=978-0-8218-4256-0|url=https://books.google.com/books?id=VpRESN24Zj0C&pg=PA19}}</ref>{{rp|19–20}}
where ''K'' is a constant (and is really just a choice of measurement units).
<math>\operatorname{I}(X)</math> is itself a random variable.


The entropy can explicitly be written as:
Shannon defined a measure of entropy (''H'' = &minus; ''p<sub>1</sub>'' log<sub>2</sub> ''p<sub>1</sub>'' &minus; &hellip; &minus; ''p<sub>n</sub>'' log<sub>2</sub> ''p<sub>n</sub>'') that, when applied to an information source, could determine the minimum channel capacity required to reliably transmit the source as encoded binary digits. The formula can be derived by calculating the mathematical expectation of the ''amount of information'' contained in a digit from the information source. Shannon's entropy measure came to be taken as a measure of the uncertainty about the realization of a random variable. It thus served as a proxy capturing the concept of information contained in a message as opposed to the portion of the message that is strictly determined (hence predictable) by inherent structures. For example, redundancy in language structure or statistical properties relating to the occurrence frequencies of letter or word pairs, triplets etc. See ].
<math display="block">\Eta(X) = -\sum_{x \in \mathcal{X}} p(x)\log_b p(x) ,</math>
where {{math|''b''}} is the ] of the ] used. Common values of {{math|''b''}} are 2, ], and 10, and the corresponding units of entropy are the ]s for {{math|''b'' {{=}} 2}}, ] for {{math|''b'' {{=}} ''e''}}, and ]s for {{math|''b'' {{=}} 10}}.<ref>Schneider, T.D, {{Dead link|date=August 2023 |bot=InternetArchiveBot |fix-attempted=yes }}, National Cancer Institute, 14 April 2007.</ref>


In the case of <math>p(x) = 0</math> for some <math>x \in \mathcal{X}</math>, the value of the corresponding summand {{math|0 log<sub>''b''</sub>(0)}} is taken to be {{math|0}}, which is consistent with the ]:<ref name=cover1991/>{{rp|13}}
===Relationship to thermodynamic entropy===
<math display="block">\lim_{p\to0^+}p\log (p) = 0.</math>
{{main|Entropy in thermodynamics and information theory}}
Shannon's definition of entropy is closely related to ] as defined in ] and ]. ] and ] did considerable work on statistical thermodynamics, which became the inspiration for adopting the word ''entropy'' in information theory. There are relationships between thermodynamic and informational entropy. In fact, in the view of ] (]), thermodynamics should be seen as an ''application'' of Shannon's information theory: the thermodynamic entropy is interpreted as being an estimate of the amount of further Shannon information (needed to define the detailed microscopic state of the system) that remains uncommunicated by a description solely in terms of the macroscopic variables of classical thermodynamics. For example, adding heat to a system increases its thermodynamic entropy because it increases the number of possible microscopic states that it could be in, thus making any complete state description longer. (See article: '']''). ] (hypothetically) reduces the thermodynamic entropy of a system using information about the states of individual molecules; however, the demon himself increases his own entropy in the process, and so the total entropy does not decrease (which resolves the paradox).


One may also define the ] of two variables <math>X</math> and <math>Y</math> taking values from sets <math>\mathcal{X}</math> and <math>\mathcal{Y}</math> respectively, as:<ref name=cover1991/>{{rp|16}}
===Entropy as information content===
<math display="block"> \Eta(X|Y)=-\sum_{x,y \in \mathcal{X} \times \mathcal{Y}} p_{X,Y}(x,y)\log\frac{p_{X,Y}(x,y)}{p_Y(y)} ,</math>
It is important to remember that entropy is a quantity defined in the context of a probabilistic model for a data source. Independent fair coin flips have an entropy of 1 bit per flip. A source that always generates a long string of A's has an entropy of 0, since the next character will always be an 'A'.
where <math>p_{X,Y}(x,y) := \mathbb{P}</math> and <math>p_Y(y) = \mathbb{P}</math>. This quantity should be understood as the remaining randomness in the random variable <math>X</math> given the random variable <math>Y</math>.


=== Measure theory ===
The entropy rate of a data source means the average number of ]s per symbol needed to encode it. Empirically, it seems that entropy of English text is between 1.1 and 1.6 bits per character, though clearly that will vary from one source of text to another. Experiments with human predictors show an information rate of 1.1 or 1.6 bits per character, depending on the experimental setup; the ] can achieve a compression ratio of 1.5 bits per character.


Entropy can be formally defined in the language of ] as follows:<ref>{{nlab|id=entropy|title=Entropy}}</ref> Let <math>(X, \Sigma, \mu)</math> be a ]. Let <math>A \in \Sigma</math> be an ]. The ] of <math>A</math> is
From the preceding example, note the following points:
<math display="block"> \sigma_\mu(A) = -\ln \mu(A) .</math>


The ''expected'' surprisal of <math>A</math> is
# The amount of entropy is not always an integer number of bits.
<math display="block"> h_\mu(A) = \mu(A) \sigma_\mu(A) .</math>
# Many data bits may not convey information. For example, data structures often store information redundantly, or have identical sections regardless of the information in the data structure.


A <math>\mu</math>-almost ] is a ] <math>P \subseteq \mathcal{P}(X)</math> such that <math>\mu(\mathop{\cup} P) = 1</math> and <math>\mu(A \cap B) = 0</math> for all distinct <math>A, B \in P</math>. (This is a relaxation of the usual conditions for a partition.) The entropy of <math>P</math> is
===Data compression===
<math display="block"> \Eta_\mu(P) = \sum_{A \in P} h_\mu(A) .</math>
Entropy effectively bounds the performance of the strongest lossless (or nearly lossless) compression possible, which can be realized in theory by using the ] or in practice using ], ] or ]. The performance of existing data compression algorithms is often used as a rough estimate of the entropy of a block of data.


Let <math>M</math> be a ] on <math>X</math>. The entropy of <math>M</math> is
===Data as a Markov process===
<math display="block"> \Eta_\mu(M) = \sup_{P \subseteq M} \Eta_\mu(P) .</math>
A common way to define entropy for text is based on the ] of text. For an order-0 source (each character is selected independent of the last characters), the binary entropy is:
Finally, the entropy of the probability space is <math>\Eta_\mu(\Sigma)</math>, that is, the entropy with respect to <math>\mu</math> of the sigma-algebra of ''all'' measurable subsets of <math>X</math>.


==Example==
:<math>H(\mathcal{S}) = - \sum p_i \log_2 p_i, \,\!</math>
] ]) of a coin flip, measured in bits, graphed versus the bias of the coin {{math|Pr(''X'' {{=}} 1)}}, where {{math|''X'' {{=}} 1}} represents a result of heads.<ref name=cover1991/>{{rp|14–15}}<br /><br />Here, the entropy is at most 1 bit, and to communicate the outcome of a coin flip (2 possible values) will require an average of at most 1 bit (exactly 1 bit for a fair coin). The result of a fair die (6 possible values) would have entropy log<sub>2</sub>6 bits.]]
{{Main|Binary entropy function|Bernoulli process}}
Consider tossing a coin with known, not necessarily fair, probabilities of coming up heads or tails; this can be modeled as a ].


The entropy of the unknown result of the next toss of the coin is maximized if the coin is fair (that is, if heads and tails both have equal probability 1/2). This is the situation of maximum uncertainty as it is most difficult to predict the outcome of the next toss; the result of each toss of the coin delivers one full bit of information. This is because
where ''p''<sub>''i''</sub> is the probability of ''i''. For a first-order ] (one in which the probability of selecting a character is dependent only on the immediately preceding character), the '''entropy rate''' is:
<math display="block">\begin{align}
\Eta(X) &= -\sum_{i=1}^n {p(x_i) \log_b p(x_i)}
\\ &= -\sum_{i=1}^2 {\frac{1}{2}\log_2{\frac{1}{2}}}
\\ &= -\sum_{i=1}^2 {\frac{1}{2} \cdot (-1)} = 1.
\end{align}</math>


However, if we know the coin is not fair, but comes up heads or tails with probabilities {{math|''p''}} and {{math|''q''}}, where {{math|''p'' ≠ ''q''}}, then there is less uncertainty. Every time it is tossed, one side is more likely to come up than the other. The reduced uncertainty is quantified in a lower entropy: on average each toss of the coin delivers less than one full bit of information. For example, if {{math|''p''}} = 0.7, then
:<math>H(\mathcal{S}) = - \sum_i p_i \sum_j \ p_i (j) \log_2 p_i (j), \,\!</math>
<math display="block">\begin{align}
\Eta(X) &= - p \log_2 (p) - q \log_2 (q)
\\ &= - 0.7 \log_2 (0.7) - 0.3 \log_2 (0.3)
\\ &\approx - 0.7 \cdot (-0.515) - 0.3 \cdot (-1.737)
\\ &= 0.8816 < 1.
\end{align}</math>


Uniform probability yields maximum uncertainty and therefore maximum entropy. Entropy, then, can only decrease from the value associated with uniform probability. The extreme case is that of a double-headed coin that never comes up tails, or a double-tailed coin that never results in a head. Then there is no uncertainty. The entropy is zero: each toss of the coin delivers no new information as the outcome of each coin toss is always certain.<ref name=cover1991/>{{rp|14–15}}
where ''i'' is a '''state''' (certain preceding characters) and <math>p_i(j)</math> is the probability of <math>j</math> given <math>i</math> as the previous character (s).


==Characterization==
For a second order Markov source, the entropy rate is
To understand the meaning of {{math|−Σ ''p''<sub>''i''</sub> log(''p''<sub>''i''</sub>)}}, first define an information function {{math|I}} in terms of an event {{math|''i''}} with probability {{math|''p''<sub>''i''</sub>}}. The amount of information acquired due to the observation of event {{math|''i''}} follows from Shannon's solution of the fundamental properties of ]:<ref>{{cite book |last=Carter |first=Tom |date=March 2014 |title=An introduction to information theory and entropy |url=http://csustan.csustan.edu/~tom/Lecture-Notes/Information-Theory/info-lec.pdf |location=Santa Fe |access-date=4 August 2017 |archive-date=4 June 2016 |archive-url=https://web.archive.org/web/20160604130248/http://csustan.csustan.edu/~tom/Lecture-Notes/Information-Theory/info-lec.pdf |url-status=live }}</ref>
# {{math|I(''p'')}} is ] in {{math|''p''}}: an increase in the probability of an event decreases the information from an observed event, and vice versa.
# {{math|I(1) {{=}} 0}}: events that always occur do not communicate information.
# {{math|I(''p''<sub>1</sub>·''p''<sub>2</sub>) {{=}} I(''p''<sub>1</sub>) + I(''p''<sub>2</sub>)}}: the information learned from ] is the sum of the information learned from each event.


Given two independent events, if the first event can yield one of {{math|''n''}} ] outcomes and another has one of {{math|''m''}} equiprobable outcomes then there are {{math|''mn''}} equiprobable outcomes of the joint event. This means that if {{math|log<sub>2</sub>(''n'')}} bits are needed to encode the first value and {{math|log<sub>2</sub>(''m'')}} to encode the second, one needs {{math|log<sub>2</sub>(''mn'') {{=}} log<sub>2</sub>(''m'') + log<sub>2</sub>(''n'')}} to encode both.
:<math> H(\mathcal{S}) = -\sum_i p_i \sum_j p_i(j) \sum_k p_{i,j}(k)\ \log \ p_{i,j}(k). \,\!</math>


Shannon discovered that a suitable choice of <math>\operatorname{I}</math> is given by:<ref>Chakrabarti, C. G., and Indranil Chakrabarty. "Shannon entropy: axiomatic characterization and application." ''International Journal of Mathematics and Mathematical Sciences'' 2005. 17 (2005): 2847-2854 {{Webarchive|url=https://web.archive.org/web/20211005135940/https://arxiv.org/pdf/quant-ph/0511171.pdf |date=5 October 2021 }}</ref>
In general the '''''b''-ary entropy''' of a source <math>\mathcal{S}</math> = (''S'',''P'') with ] ''S'' = {''a''<sub>1</sub>, &hellip;, ''a<sub>n</sub>''} and ] ''P'' = {''p''<sub>1</sub>, &hellip;, ''p<sub>n</sub>''} where ''p<sub>i</sub>'' is the probability of ''a<sub>i</sub>'' (say ''p<sub>i</sub>'' = ''p''(''a<sub>i</sub>'')) is defined by:
<math display="block">\operatorname{I}(p) = \log\left(\tfrac{1}{p}\right) = -\log(p).</math>


In fact, the only possible values of <math>\operatorname{I}</math> are <math>\operatorname{I}(u) = k \log u</math> for <math>k<0</math>. Additionally, choosing a value for {{math|''k''}} is equivalent to choosing a value <math>x>1</math> for <math>k = - 1/\log x</math>, so that {{math|''x''}} corresponds to the ]. Thus, entropy is ] by the above four properties.
:<math> H_b(\mathcal{S}) = - \sum_{i=1}^n p_i \log_b p_i \,\!</math>


:{| class="toccolours collapsible collapsed" width="80%" style="text-align:left"
Note: the ''b'' in "''b''-ary entropy" is the number of different symbols of the "ideal alphabet" which is being used as the standard yardstick to measure source alphabets. In information theory, two symbols are ] for an alphabet to be able to encode information, therefore the default is to let ''b'' = 2 ("binary entropy"). Thus, the entropy of the source alphabet, with its given empiric probability distribution, is a number equal to the number (possibly fractional) of symbols of the "ideal alphabet", with an optimal probability distribution, necessary to encode for each symbol of the source alphabet. Also note that "optimal probability distribution" here means a ]: a source alphabet with ''n'' symbols has the highest possible entropy (for an alphabet with ''n'' symbols) when the probability distribution of the alphabet is uniform. This optimal entropy turns out to be <math> \log_b \, n </math>.
!Proof
|-
|Let <math display="inline">\operatorname{I}</math> be the information function which one assumes to be twice continuously differentiable, one has:


:<math>\begin{align}
===Alternative definition===
& \operatorname{I}(p_1 p_2) &=\ & \operatorname{I}(p_1) + \operatorname{I}(p_2) && \quad \text{Starting from property 3} \\
Another way to define the entropy function ''H'' (not using the ]) is by proving that ''H'' is uniquely defined (as earlier mentioned) if and only if ''H'' satisfies the following conditions:
& p_2 \operatorname{I}'(p_1 p_2) &=\ & \operatorname{I}'(p_1) && \quad \text{taking the derivative w.r.t}\ p_1 \\
& \operatorname{I}'(p_1 p_2) + p_1 p_2 \operatorname{I}''(p_1 p_2) &=\ & 0 && \quad \text{taking the derivative w.r.t}\ p_2 \\
& \operatorname{I}'(u) + u \operatorname{I}''(u) &=\ & 0 && \quad \text{introducing}\, u = p_1 p_2 \\
& (u\operatorname{I}'(u))' &=\ & 0 && \quad \text{combining terms into one}\ \\
& u\operatorname{I}'(u) - k &=\ & 0 && \quad \text{integrating w.r.t}\ u, \text{producing constant}\, k \\
\end{align}</math>


This ] leads to the solution <math>\operatorname{I}(u) = k \log u + c</math> for some <math>k, c \in \mathbb{R}</math>. Property 2 gives <math>c = 0</math>. Property 1 and 2 give that <math>\operatorname{I}(p)\ge 0</math> for all <math>p\in </math>, so that <math>k < 0</math>.
1. ''H''(''p''<sub>1</sub>, &hellip;, ''p<sub>n</sub>'') is ] and ] ] ''p''<sub>1</sub>, &hellip;, ''p<sub>n</sub>'' where ''p<sub>i</sub>'' <math>\in</math> ] ''i'' = 1, &hellip;, ''n'' and ''p''<sub>1</sub> + &hellip; + ''p<sub>n</sub>'' = 1. (Remark that the function solely depends on the probability distribution, not the alphabet.)
|}


The different ] (]s for the ] {{math|log<sub>2</sub>}}, ] for the ] {{math|ln}}, ] for the ] {{math|log<sub>10</sub>}} and so on) are ] of each other. For instance, in case of a fair coin toss, heads provides {{math|log<sub>2</sub>(2) {{=}} 1}} bit of information, which is approximately 0.693&nbsp;nats or 0.301&nbsp;decimal digits. Because of additivity, {{math|''n''}} tosses provide {{math|''n''}} bits of information, which is approximately {{math|0.693''n''}} nats or {{math|0.301''n''}} decimal digits.
2. ] ] ''n'', ''H'' satisfies


The ''meaning'' of the events observed (the meaning of ''messages'') does not matter in the definition of entropy. Entropy only takes into account the probability of observing a specific event, so the information it encapsulates is information about the underlying ], not the meaning of the events themselves.
:<math>
H\underbrace{\left(\frac{1}{n}, \ldots, \frac{1}{n}\right)}_{n\ \mathrm{arguments}} < H\underbrace{\left(\frac{1}{n+1}, \ldots, \frac{1}{n+1}\right).}_{n+1\ \mathrm{arguments}}
</math>


===Alternative characterization===
3. For ] ''b<sub>i</sub>'' where ''b''<sub>1</sub> + &hellip; + ''b<sub>k</sub>'' = ''n'', ''H'' satisfies
Another characterization of entropy uses the following properties. We denote {{math|''p''<sub>''i''</sub> {{=}} Pr(''X'' {{=}} ''x''<sub>''i''</sub>)}} and {{math|Η<sub>''n''</sub>(''p''<sub>1</sub>, ..., ''p''<sub>''n''</sub>) {{=}} Η(''X'')}}.


# Continuity: {{math|H}} should be ], so that changing the values of the probabilities by a very small amount should only change the entropy by a small amount.
:<math>
# Symmetry: {{math|H}} should be unchanged if the outcomes {{math|''x''<sub>''i''</sub>}} are re-ordered. That is, <math>\Eta_n\left(p_1, p_2, \ldots p_n \right) = \Eta_n\left(p_{i_1}, p_{i_2}, \ldots, p_{i_n} \right)</math> for any ] <math>\{i_1, ..., i_n\}</math> of <math>\{1, ..., n\}</math>.
H\underbrace{\left(\frac{1}{n}, \ldots, \frac{1}{n}\right)}_n = H\underbrace{\left(\frac{b_1}{n}, \ldots, \frac{b_k}{n}\right)}_k + \sum_{i=1}^k \frac{b_i}{n} H\underbrace{\left(\frac{1}{b_i}, \ldots, \frac{1}{b_i}\right)}_{b_i}.
# Maximum: <math>\Eta_n</math> should be maximal if all the outcomes are equally likely i.e. <math>\Eta_n(p_1,\ldots,p_n) \le \Eta_n\left(\frac{1}{n}, \ldots, \frac{1}{n}\right)</math>.
</math>
# Increasing number of outcomes: for equiprobable events, the entropy should increase with the number of outcomes i.e. <math>\Eta_n\bigg(\underbrace{\frac{1}{n}, \ldots, \frac{1}{n}}_{n}\bigg) < \Eta_{n+1}\bigg(\underbrace{\frac{1}{n+1}, \ldots, \frac{1}{n+1}}_{n+1}\bigg).</math>
# Additivity: given an ensemble of {{math|''n''}} uniformly distributed elements that are partitioned into {{math|''k''}} boxes (sub-systems) with {{math|''b''<sub>1</sub>, ..., ''b''<sub>''k''</sub>}} elements each, the entropy of the whole ensemble should be equal to the sum of the entropy of the system of boxes and the individual entropies of the boxes, each weighted with the probability of being in that particular box.


==== Discussion ====
==Efficiency==
The rule of additivity has the following consequences: for ] {{math|''b''<sub>''i''</sub>}} where {{math|''b''<sub>1</sub> + ... + ''b''<sub>''k''</sub> {{=}} ''n''}},
A source alphabet encountered in practice should be found to have a probability distribution which is less than optimal. If the source alphabet has ''n'' symbols, then it can be compared to an "optimized alphabet" with ''n'' symbols, whose probability distribution is uniform. The ratio of the entropy of the source alphabet with the entropy of its optimized version is the efficiency of the source alphabet, which can be expressed as a ].
:<math>\Eta_n\left(\frac{1}{n}, \ldots, \frac{1}{n}\right) = \Eta_k\left(\frac{b_1}{n}, \ldots, \frac{b_k}{n}\right) + \sum_{i=1}^k \frac{b_i}{n} \, \Eta_{b_i}\left(\frac{1}{b_i}, \ldots, \frac{1}{b_i}\right).</math>


This implies that the efficiency of a source alphabet with ''n'' symbols can be defined simply as being equal to its ''n''-ary entropy. See also ]. Choosing {{math|''k'' {{=}} ''n''}}, {{math|''b''<sub>1</sub> {{=}} ... {{=}} ''b''<sub>''n''</sub> {{=}} 1}} this implies that the entropy of a certain outcome is zero: {{math|Η<sub>1</sub>(1) {{=}} 0}}. This implies that the efficiency of a source set with {{math|''n''}} symbols can be defined simply as being equal to its {{math|''n''}}-ary entropy. See also ].


The characterization here imposes an additive property with respect to a ]. Meanwhile, the ] is defined in terms of a multiplicative property, <math>P(A\mid B)\cdot P(B)=P(A\cap B)</math>. Observe that a logarithm mediates between these two operations. The ] and related quantities inherit simple relation, in turn. The measure theoretic definition in the previous section defined the entropy as a sum over expected surprisals <math>\mu(A)\cdot \ln\mu(A)</math> for an extremal partition. Here the logarithm is ad hoc and the entropy is not a measure in itself. At least in the information theory of a binary string, <math>\log_2</math> lends itself to practical interpretations.
==Derivation of Shannon's entropy==
Since the entropy was given as a definition, it does not need to be derived. On the other hand, a "derivation" can be given which gives a sense of the motivation for the definition as well as the link to thermodynamic entropy.


Motivated by such relations, a plethora of related and competing quantities have been defined. For example, ]'s analysis of a "logic of partitions" defines a competing measure in structures ] to that of subsets of a universal set.<ref>{{cite journal |last1=Ellerman |first1=David |title=Logical Information Theory: New Logical Foundations for Information Theory |journal=Logic Journal of the IGPL |date=October 2017 |volume=25 |issue=5 |pages=806–835 |doi=10.1093/jigpal/jzx022 |url=http://philsci-archive.pitt.edu/13213/1/Logic-to-information-theory3.pdf |access-date=2 November 2022 |archive-date=25 December 2022 |archive-url=https://web.archive.org/web/20221225080028/https://philsci-archive.pitt.edu/13213/1/Logic-to-information-theory3.pdf |url-status=live }}</ref> Information is quantified as "dits" (distinctions), a measure on partitions. "Dits" can be converted into ], to get the formulas for conditional entropy, and so on.
'''Q.''' Given a ] with ''n'' pockets which are all equally likely to be landed on by the ball, what is the probability of obtaining a distribution (''A<sub>1</sub>'', ''A<sub>2</sub>'', &hellip;, ''A<sub>n</sub>'') where ''A<sub>i</sub>'' is the number of times pocket ''i'' was landed on and


===Alternative characterization via additivity and subadditivity===
:<math> P = \sum_{i=1}^n A_i \,\!</math>


Another succinct axiomatic characterization of Shannon entropy was given by ], Forte and Ng,<ref name="aczelentropy">{{cite journal|last1=Aczél|first1=J.|title=Why the Shannon and Hartley entropies are 'natural'|last2=Forte|first2=B.|last3=Ng|first3=C. T.|journal=Advances in Applied Probability|date=1974|volume=6|issue=1|pages=131–146|doi=10.2307/1426210 |jstor=1426210 |s2cid=204177762 }}</ref> via the following properties:
is the total number of ball-landing events?


# Subadditivity: <math>\Eta(X,Y) \le \Eta(X)+\Eta(Y)</math> for jointly distributed random variables <math>X,Y</math>.
'''A.''' The probability is a ], viz.
# Additivity: <math>\Eta(X,Y) = \Eta(X)+\Eta(Y)</math> when the random variables <math>X,Y</math> are independent.
# Expansibility: <math>\Eta_{n+1}(p_1, \ldots, p_n, 0) = \Eta_n(p_1, \ldots, p_n)</math>, i.e., adding an outcome with probability zero does not change the entropy.
# Symmetry: <math>\Eta_n(p_1, \ldots, p_n)</math> is invariant under permutation of <math>p_1, \ldots, p_n</math>.
# Small for small probabilities: <math>\lim_{q \to 0^+} \Eta_2(1-q, q) = 0</math>.


==== Discussion ====
:<math> p = {\Omega \over \Tau} = {P! \over A_1! \ A_2! \ A_3! \ \cdots \ A_n!} \left(\frac1n\right)^P \,\!</math>
It was shown that any function <math>\Eta</math> satisfying the above properties must be a constant multiple of Shannon entropy, with a non-negative constant.<ref name="aczelentropy"/> Compared to the previously mentioned characterizations of entropy, this characterization focuses on the properties of entropy as a function of random variables (subadditivity and additivity), rather than the properties of entropy as a function of the probability vector <math>p_1,\ldots ,p_n</math>.


It is worth noting that if we drop the "small for small probabilities" property, then <math>\Eta</math> must be a non-negative linear combination of the Shannon entropy and the ].<ref name="aczelentropy"/>
where


==Further properties==
:<math> \Omega = {P! \over A_1! \ A_2! \ A_3! \ \cdots \ A_n!} \,\!</math>
The Shannon entropy satisfies the following properties, for some of which it is useful to interpret entropy as the expected amount of information learned (or uncertainty eliminated) by revealing the value of a random variable {{math|''X''}}:


* Adding or removing an event with probability zero does not contribute to the entropy:
is the number of possible combinations of outcomes (for the events) which fit the given distribution, and
::<math>\Eta_{n+1}(p_1,\ldots,p_n,0) = \Eta_n(p_1,\ldots,p_n)</math>.
* The maximal entropy of an event with ''n'' different outcomes is {{math|log<sub>''b''</sub>(''n'')}}: it is attained by the uniform probability distribution. That is, uncertainty is maximal when all possible events are equiprobable:
::<math>\Eta(p_1,\dots,p_n) \leq \log_b n</math>.<ref name=cover1991>{{cite book |author1=Thomas M. Cover |author2=Joy A. Thomas |title=Elements of Information Theory |publisher=Wiley |location=Hoboken, New Jersey |isbn=978-0-471-24195-9|date=1991}}</ref>{{rp|29}}
* The entropy or the amount of information revealed by evaluating {{math|(''X'',''Y'')}} (that is, evaluating {{math|''X''}} and {{math|''Y''}} simultaneously) is equal to the information revealed by conducting two consecutive experiments: first evaluating the value of {{math|''Y''}}, then revealing the value of {{math|''X''}} given that you know the value of {{math|''Y''}}. This may be written as:<ref name=cover1991/>{{rp|16}}
::<math> \Eta(X,Y)=\Eta(X|Y)+\Eta(Y)=\Eta(Y|X)+\Eta(X).</math>
* If <math>Y=f(X)</math> where <math>f</math> is a function, then <math>\Eta(f(X)|X) = 0</math>. Applying the previous formula to <math>\Eta(X,f(X))</math> yields
::<math> \Eta(X)+\Eta(f(X)|X)=\Eta(f(X))+\Eta(X|f(X)),</math>
:so <math>\Eta(f(X)) \le \Eta(X)</math>, the entropy of a variable can only decrease when the latter is passed through a function.
* If {{math|''X''}} and {{math|''Y''}} are two independent random variables, then knowing the value of {{math|''Y''}} doesn't influence our knowledge of the value of {{math|''X''}} (since the two don't influence each other by independence):
::<math> \Eta(X|Y)=\Eta(X).</math>
* More generally, for any random variables {{math|''X''}} and {{math|''Y''}}, we have
::<math> \Eta(X|Y)\leq \Eta(X)</math>.<ref name=cover1991/>{{rp|29}}
* The entropy of two simultaneous events is no more than the sum of the entropies of each individual event i.e., <math> \Eta(X,Y)\leq \Eta(X)+\Eta(Y)</math>, with equality if and only if the two events are independent.<ref name=cover1991/>{{rp|28}}
* The entropy <math>\Eta(p)</math> is ] in the probability mass function <math>p</math>, i.e.<ref name=cover1991/>{{rp|30}}
::<math>\Eta(\lambda p_1 + (1-\lambda) p_2) \ge \lambda \Eta(p_1) + (1-\lambda) \Eta(p_2)</math>
:for all probability mass functions <math>p_1,p_2</math> and <math> 0 \le \lambda \le 1</math>.<ref name=cover1991 />{{rp|32}}
:* Accordingly, the ] (negentropy) function is convex, and its ] is ].


==Aspects==
:<math> \Tau = n^P \ </math>


===Relationship to thermodynamic entropy===
is the number of all possible combinations of outcomes for the set of ''P'' events.
{{Main|Entropy in thermodynamics and information theory}}
The inspiration for adopting the word ''entropy'' in information theory came from the close resemblance between Shannon's formula and very similar known formulae from ].


In ] the most general formula for the thermodynamic ] {{math|''S''}} of a ] is the ]
'''Q.''' And what is the entropy?
:<math>S = - k_\text{B} \sum p_i \ln p_i \,,</math>
where {{math|''k''<sub>B</sub>}} is the ], and {{math|''p''<sub>''i''</sub>}} is the probability of a ]. The ] was defined by ] in 1878 after earlier work by ] (1872).<ref>Compare: Boltzmann, Ludwig (1896, 1898). Vorlesungen über Gastheorie : 2 Volumes – Leipzig 1895/98 UB: O 5262-6. English version: Lectures on gas theory. Translated by Stephen G. Brush (1964) Berkeley: University of California Press; (1995) New York: Dover {{isbn|0-486-68455-5}}</ref>


The Gibbs entropy translates over almost unchanged into the world of ] to give the ] introduced by ] in 1927:
'''A.''' The entropy of the distribution is obtained from the ] of &Omega;:
:<math> H = \log \Omega = \log \frac{P!}{A_1! \ A_2! \ A_3! \cdots \ A_n!} \,\!</math> :<math>S = - k_\text{B} \,{\rm Tr}(\rho \ln \rho) \,,</math>
where ρ is the ] of the quantum mechanical system and Tr is the ].<ref>{{Cite book|last=Życzkowski|first=Karol|title=Geometry of Quantum States: An Introduction to Quantum Entanglement|publisher=Cambridge University Press|year=2006|pages=301}}</ref>


At an everyday practical level, the links between information entropy and thermodynamic entropy are not evident. Physicists and chemists are apt to be more interested in ''changes'' in entropy as a system spontaneously evolves away from its initial conditions, in accordance with the ], rather than an unchanging probability distribution. As the minuteness of the ] {{math|''k''<sub>B</sub>}} indicates, the changes in {{math|''S'' / ''k''<sub>B</sub>}} for even tiny amounts of substances in chemical and physical processes represent amounts of entropy that are extremely large compared to anything in ] or ]. In classical thermodynamics, entropy is defined in terms of macroscopic measurements and makes no reference to any probability distribution, which is central to the definition of information entropy.
::<math> = \log P! - \log A_1! - \log A_2! - \log A_3! - \cdots - \log A_n! \ </math>


The connection between thermodynamics and what is now known as information theory was first made by ] and expressed by his ]:
::<math> = \sum_i^P \log i - \sum_i^{A_1} \log i - \sum_i^{A_2} \log i - \cdots - \sum_i^{A_n} \log i \,\!</math>


:<math>S=k_\text{B} \ln W,</math>
The summations can be approximated closely by being replaced with integrals:


where <math>S</math> is the thermodynamic entropy of a particular macrostate (defined by thermodynamic parameters such as temperature, volume, energy, etc.), {{math|''W''}} is the number of microstates (various combinations of particles in various energy states) that can yield the given macrostate, and {{math|''k''<sub>B</sub>}} is the ].<ref>{{Cite journal|last1=Sharp|first1=Kim|last2=Matschinsky|first2=Franz|date=2015|title=Translation of Ludwig Boltzmann's Paper "On the Relationship between the Second Fundamental Theorem of the Mechanical Theory of Heat and Probability Calculations Regarding the Conditions for Thermal Equilibrium"|journal=Entropy|volume=17|pages=1971–2009|doi=10.3390/e17041971|doi-access=free}}</ref> It is assumed that each microstate is equally likely, so that the probability of a given microstate is {{math|1=''p''<sub>''i''</sub> = 1/''W''}}. When these probabilities are substituted into the above expression for the Gibbs entropy (or equivalently {{math|''k''<sub>B</sub>}} times the Shannon entropy), Boltzmann's equation results. In information theoretic terms, the information entropy of a system is the amount of "missing" information needed to determine a microstate, given the macrostate.
:<math> H = \int_1^P \log x \, dx - \int_1^{A_1} \log x \, dx - \int_1^{A_2} \log x \, dx - \cdots - \int_1^{A_n} \log x \, dx. \,\!</math>


In the view of ] (1957),<ref>{{Cite journal|last=Jaynes|first=E. T.|date=1957-05-15|title=Information Theory and Statistical Mechanics|url=https://link.aps.org/doi/10.1103/PhysRev.106.620|journal=Physical Review|volume=106|issue=4|pages=620–630|doi=10.1103/PhysRev.106.620|bibcode=1957PhRv..106..620J|s2cid=17870175 }}</ref> thermodynamic entropy, as explained by ], should be seen as an ''application'' of Shannon's information theory: the thermodynamic entropy is interpreted as being proportional to the amount of further Shannon information needed to define the detailed microscopic state of the system, that remains uncommunicated by a description solely in terms of the macroscopic variables of classical thermodynamics, with the constant of proportionality being just the ]. Adding heat to a system increases its thermodynamic entropy because it increases the number of possible microscopic states of the system that are consistent with the measurable values of its macroscopic variables, making any complete state description longer. (See article: '']''). ] can (hypothetically) reduce the thermodynamic entropy of a system by using information about the states of individual molecules; but, as ] (from 1961) and co-workers<ref>{{Cite journal|last=Landauer|first=R.|date=July 1961|title=Irreversibility and Heat Generation in the Computing Process|url=https://ieeexplore.ieee.org/document/5392446|journal=IBM Journal of Research and Development|volume=5|issue=3|pages=183–191|doi=10.1147/rd.53.0183|issn=0018-8646|access-date=15 December 2021|archive-date=15 December 2021|archive-url=https://web.archive.org/web/20211215235046/https://ieeexplore.ieee.org/document/5392446|url-status=live}}</ref> have shown, to function the demon himself must increase thermodynamic entropy in the process, by at least the amount of Shannon information he proposes to first acquire and store; and so the total thermodynamic entropy does not decrease (which resolves the paradox). ] imposes a lower bound on the amount of heat a computer must generate to process a given amount of information, though modern computers are far less efficient.
The integral of the logarithm is


===Data compression===
:<math> \int \log x \, dx = x \log x - \int x \, {dx \over x} = x \log x - x. \,\!</math>
{{Main|Shannon's source coding theorem|Data compression}}
Shannon's definition of entropy, when applied to an information source, can determine the minimum channel capacity required to reliably transmit the source as encoded binary digits. Shannon's entropy measures the information contained in a message as opposed to the portion of the message that is determined (or predictable). Examples of the latter include redundancy in language structure or statistical properties relating to the occurrence frequencies of letter or word pairs, triplets etc. The minimum channel capacity can be realized in theory by using the ] or in practice using ], ] or ]. (See also ].) In practice, compression algorithms deliberately include some judicious redundancy in the form of ]s to protect against errors. The ] of a data source is the average number of bits per symbol needed to encode it. Shannon's experiments with human predictors show an information rate between 0.6 and 1.3 bits per character in English;<ref>{{cite web |url=http://marknelson.us/2006/08/24/the-hutter-prize/ |title=The Hutter Prize |access-date=2008-11-27 |date=24 August 2006 |author=Mark Nelson |archive-date=1 March 2018 |archive-url=https://web.archive.org/web/20180301161215/http://marknelson.us/2006/08/24/the-hutter-prize/ |url-status=dead }}</ref> the ] can achieve a compression ratio of 1.5 bits per character in English text.


If a ] scheme is lossless – one in which you can always recover the entire original message by decompression – then a compressed message has the same quantity of information as the original but is communicated in fewer characters. It has more information (higher entropy) per character. A compressed message has less ]. ] states a lossless compression scheme cannot compress messages, on average, to have ''more'' than one bit of information per bit of message, but that any value ''less'' than one bit of information per bit of message can be attained by employing a suitable coding scheme. The entropy of a message per bit multiplied by the length of that message is a measure of how much total information the message contains. Shannon's theorem also implies that no lossless compression scheme can shorten ''all'' messages. If some messages come out shorter, at least one must come out longer due to the ]. In practical use, this is generally not a problem, because one is usually only interested in compressing certain types of messages, such as a document in English, as opposed to gibberish text, or digital photographs rather than noise, and it is unimportant if a compression algorithm makes some unlikely or uninteresting sequences larger.
So the entropy is


A 2011 study in '']'' estimates the world's technological capacity to store and communicate optimally compressed information normalized on the most effective compression algorithms available in the year 2007, therefore estimating the entropy of the technologically available sources.<ref name="HilbertLopez2011"> {{Webarchive|url=https://web.archive.org/web/20130727161911/http://www.sciencemag.org/content/332/6025/60 |date=27 July 2013 }}, Martin Hilbert and Priscila López (2011), '']'', 332(6025); free access to the article through here: martinhilbert.net/WorldInfoCapacity.html</ref>{{rp|60–65}}
:<math> H = (P \log P - P + 1) - (A_1 \log A_1 - A_1 + 1) - (A_2 \log A_2 - A_2 + 1) - \cdots - (A_n \log A_n - A_n + 1) </math>
{| class="wikitable"
::<math> = (P \log P + 1) - (A_1 \log A_1 + 1) - (A_2 \log A_2 + 1) - \cdots - (A_n \log A_n + 1) </math>
|+
::<math> = P \log P - \sum_{x=1}^n A_x \log A_x + (1 - n) \,\!</math>
All figures in entropically compressed ]
|-
! Type of Information !! 1986 !! 2007
|-
| Storage || 2.6 || 295
|-
| Broadcast || 432 || 1900
|-
| Telecommunications || 0.281 || 65
|}
The authors estimate humankind technological capacity to store information (fully entropically compressed) in 1986 and again in 2007. They break the information into three categories—to store information on a medium, to receive information through one-way ] networks, or to exchange information through two-way ]s.<ref name="HilbertLopez2011"/>


===Entropy as a measure of diversity===
By using ''p<sub>x</sub> = A<sub>x</sub>/P'' and doing some simple algebra we obtain:
{{Main|Diversity index}}
Entropy is one of several ways to measure biodiversity and is applied in the form of the ].<ref>{{Cite journal|last1=Spellerberg|first1=Ian F.|last2=Fedor|first2=Peter J.|date=2003|title=A tribute to Claude Shannon (1916–2001) and a plea for more rigorous use of species richness, species diversity and the 'Shannon–Wiener' Index|journal=Global Ecology and Biogeography|language=en|volume=12|issue=3|pages=177–179|doi=10.1046/j.1466-822X.2003.00015.x|bibcode=2003GloEB..12..177S |s2cid=85935463 |issn=1466-8238|doi-access=free}}</ref> A diversity index is a quantitative statistical measure of how many different types exist in a dataset, such as species in a community, accounting for ecological ], ], and ]. Specifically, Shannon entropy is the logarithm of {{math|<sup>1</sup>D}}, the ] index with parameter equal to 1. The Shannon index is related to the proportional abundances of types.


===Entropy of a sequence===
:<math> H = (1 - n) - \sum_{x=1}^n p_x \log p_x \,\!</math>
There are a number of entropy-related concepts that mathematically quantify information content of a sequence or message:
* the ''']''' of an individual message or symbol taken from a given probability distribution (message or sequence seen as an individual event),
* the ''']''' of the symbols forming the message or sequence (seen as a set of events),
* the ''']''' of a ] (message or sequence is seen as a succession of events).
(The "rate of self-information" can also be defined for a particular sequence of messages or symbols generated by a given stochastic process: this will always be equal to the entropy rate in the case of a ].) Other ] are also used to compare or relate different sources of information.


It is important not to confuse the above concepts. Often it is only clear from context which one is meant. For example, when someone says that the "entropy" of the English language is about 1 bit per character, they are actually modeling the English language as a stochastic process and talking about its entropy ''rate''. Shannon himself used the term in this way.
and the term (1 &minus; ''n'') can be dropped since it is a constant, independent of the ''p<sub>x</sub>'' distribution. The result is


If very large blocks are used, the estimate of per-character entropy rate may become artificially low because the probability distribution of the sequence is not known exactly; it is only an estimate. If one considers the text of every book ever published as a sequence, with each symbol being the text of a complete book, and if there are {{math|''N''}} published books, and each book is only published once, the estimate of the probability of each book is {{math|1/''N''}}, and the entropy (in bits) is {{math|−log<sub>2</sub>(1/''N'') {{=}} log<sub>2</sub>(''N'')}}. As a practical code, this corresponds to assigning each book a ] and using it in place of the text of the book whenever one wants to refer to the book. This is enormously useful for talking about books, but it is not so useful for characterizing the information content of an individual book, or of language in general: it is not possible to reconstruct the book from its identifier without knowing the probability distribution, that is, the complete text of all the books. The key idea is that the complexity of the probabilistic model must be considered. ] is a theoretical generalization of this idea that allows the consideration of the information content of a sequence independent of any particular probability model; it considers the shortest ] for a ] that outputs the sequence. A code that achieves the entropy rate of a sequence for a given model, plus the codebook (i.e. the probabilistic model), is one such program, but it may not be the shortest.
:<math> H = - \sum_{x=1}^n p_x \log p_x \,\!</math>.


The Fibonacci sequence is 1, 1, 2, 3, 5, 8, 13, .... treating the sequence as a message and each number as a symbol, there are almost as many symbols as there are characters in the message, giving an entropy of approximately {{math|log<sub>2</sub>(''n'')}}. The first 128 symbols of the Fibonacci sequence has an entropy of approximately 7 bits/symbol, but the sequence can be expressed using a formula and this formula has a much lower entropy and applies to any length of the Fibonacci sequence.
Thus, the Shannon entropy is a consequence of the equation


===Limitations of entropy in cryptography===
:<math> H = \log \Omega \ </math>
In ], entropy is often roughly used as a measure of the unpredictability of a cryptographic key, though its real ] is unmeasurable. For example, a 128-bit key that is uniformly and randomly generated has 128 bits of entropy. It also takes (on average) <math>2^{127}</math> guesses to break by brute force. Entropy fails to capture the number of guesses required if the possible keys are not chosen uniformly.<ref>{{cite conference |first1=James |last1=Massey |year=1994 |title=Guessing and Entropy |book-title=Proc. IEEE International Symposium on Information Theory |url=http://www.isiweb.ee.ethz.ch/archive/massey_pub/pdf/BI633.pdf |access-date=31 December 2013 |archive-date=1 January 2014 |archive-url=https://web.archive.org/web/20140101065020/http://www.isiweb.ee.ethz.ch/archive/massey_pub/pdf/BI633.pdf |url-status=live }}</ref><ref>{{cite conference |first1=David |last1=Malone |first2=Wayne |last2=Sullivan |year=2005 |title=Guesswork is not a Substitute for Entropy |book-title=Proceedings of the Information Technology & Telecommunications Conference |url=http://www.maths.tcd.ie/~dwmalone/p/itt05.pdf |access-date=31 December 2013 |archive-date=15 April 2016 |archive-url=https://web.archive.org/web/20160415054357/http://www.maths.tcd.ie/~dwmalone/p/itt05.pdf |url-status=live }}</ref> Instead, a measure called ''guesswork'' can be used to measure the effort required for a brute force attack.<ref>{{cite conference |first1=John |last1=Pliam |title=Selected Areas in Cryptography |year=1999 |chapter=Guesswork and variation distance as measures of cipher security|series=Lecture Notes in Computer Science |volume=1758 |pages=62–77 |book-title=International Workshop on Selected Areas in Cryptography |doi=10.1007/3-540-46513-8_5 |isbn=978-3-540-67185-5 |doi-access=free }}</ref>


Other problems may arise from non-uniform distributions used in cryptography. For example, a 1,000,000-digit binary ] using exclusive or. If the pad has 1,000,000 bits of entropy, it is perfect. If the pad has 999,999 bits of entropy, evenly distributed (each individual bit of the pad having 0.999999 bits of entropy) it may provide good security. But if the pad has 999,999 bits of entropy, where the first bit is fixed and the remaining 999,999 bits are perfectly random, the first bit of the ciphertext will not be encrypted at all.
which relates to Boltzmann's definition,


===Data as a Markov process===
:<math> \mathcal{S} = k \ln \Omega </math>,
A common way to define entropy for text is based on the ] of text. For an order-0 source (each character is selected independent of the last characters), the binary entropy is:


:<math>\Eta(\mathcal{S}) = - \sum p_i \log p_i ,</math>
of thermodynamic entropy, where ''k'' is the ].


where {{math|''p''<sub>''i''</sub>}} is the probability of {{math|''i''}}. For a first-order ] (one in which the probability of selecting a character is dependent only on the immediately preceding character), the ''']''' is:
==Properties of Shannon's information entropy==


:<math>\Eta(\mathcal{S}) = - \sum_i p_i \sum_j \ p_i (j) \log p_i (j) ,</math> {{citation needed|date=April 2013}}
We write ''H''(''X'') as ''H<sub>n</sub>''(''p<sub>1</sub>'',...,''p<sub>n</sub>''). The Shannon entropy satisfies the following properties:


where {{math|''i''}} is a '''state''' (certain preceding characters) and <math>p_i(j)</math> is the probability of {{math|''j''}} given {{math|''i''}} as the previous character.
* For any ''n'', ''H<sub>n</sub>''(''p<sub>1</sub>'',...,''p<sub>n</sub>'') is a continuous and symmetric function on variables ''p<sub>1</sub>'', ''p<sub>2</sub>'',...,''p<sub>n</sub>''.
* Event of probability zero does not contribute to the entropy, i.e. for any ''n'',
:<math>H_{n+1}(p_1,\ldots,p_n,0) = H_n(p_1,\ldots,p_n)</math>.
* Entropy is maximized when the probability distribution is uniform. For all ''n'',
:<math>H_n(p_1,\ldots,p_n) \leq H_n\Big(\frac{1}{n},\ldots,\frac{1}{n} \Big)</math>.
Following from the ],
:<math>H(X) = E\Big \leq \log_b \Big( E\Big \Big) = \log_b(n)</math>.
* If <math>p_{ij}, 1\leq i \leq m, 1\leq j \leq n</math> are non-negative real numbers summing up to one, and <math>q_i = \sum_{j=1}^n p_{ij}</math>, then
:<math>H_{mn}(p_{11},\ldots, p_{mn}) = H_m(q_1,\ldots,q_m) + \sum_{i=1}^m q_i H_n\Big(\frac{p_{i1}}{q_i},\ldots, \frac{p_{in}}{q_i} \Big)</math>.
If we partition the ''mn'' outcomes of the random experiment into ''m'' groups with each group containing ''n'' elements, we can do the experiment in two steps: first, determine the group to which the actual outcome belongs; then, find the outcome in that group. The probability that you will observe group ''i'' is ''q<sub>i</sub>''. The conditional probability distribution function for group ''i'' is ''p<sub>i1</sub>''/''q<sub>i</sub>'',...,''p<sub>in</sub>''/''q<sub>i</sub>''). The entropy
:<math>H_n\Big(\frac{p_{i1}}{q_i},\ldots, \frac{p_{in}}{q_i} \Big)</math>
is the entropy of the probability distribution conditioned on group ''i''. This property means that the total information is the sum of the information gained in the first step, ''H<sub>m</sub>''(''q<sub>1</sub>'',..., ''q<sub>n</sub>''), and a weighted sum of the entropies conditioned on each group.


For a second order Markov source, the entropy rate is
Khinchin in 1957 showed that the only function satisfying the above assumptions is of the form
:<math>H_n(p_1,\ldots,p_n) = -k \sum_{i=1}^n p_i \log p_i</math>,
where ''k'' is a positive constant representing the desired unit of measurement.


:<math>\Eta(\mathcal{S}) = -\sum_i p_i \sum_j p_i(j) \sum_k p_{i,j}(k)\ \log \ p_{i,j}(k) .</math>
==Extending discrete entropy to the continuous case: differential entropy==


==Efficiency (normalized entropy)==
The Shannon entropy is restricted to finite sets. It seems that the formula
A source set <math>\mathcal{X}</math> with a non-uniform distribution will have less entropy than the same set with a uniform distribution (i.e. the "optimized alphabet"). This deficiency in entropy can be expressed as a ratio called efficiency:<ref>Indices of Qualitative Variation.
AR Wilcox - 1967 https://www.osti.gov/servlets/purl/4167340</ref>


:<math>h = -\int_{-\infty}^{\infty} f(x) \log f(x)\, dx,\quad (*)</math> :<math>\eta(X) = \frac{H}{H_{max}} = -\sum_{i=1}^n \frac{p(x_i) \log_b (p(x_i))}{\log_b (n)}.
</math>
Applying the basic properties of the logarithm, this quantity can also be expressed as:
:<math>\eta(X) = -\sum_{i=1}^n \frac{p(x_i) \log_b (p(x_i))}{\log_b (n)} = \sum_{i=1}^n \frac{\log_b(p(x_i)^{-p(x_i)})}{\log_b(n)} =
\sum_{i=1}^n \log_n(p(x_i)^{-p(x_i)}) =
\log_n (\prod_{i=1}^n p(x_i)^{-p(x_i)}).
</math>


Efficiency has utility in quantifying the effective use of a ]. This formulation is also referred to as the normalized entropy, as the entropy is divided by the maximum entropy <math>{\log_b (n)}</math>. Furthermore, the efficiency is indifferent to the choice of (positive) base {{math|''b''}}, as indicated by the insensitivity within the final logarithm above thereto.
where ''f'' denotes a ] on the real line, is analogous to the Shannon entropy and could thus be viewed as an extension of the Shannon entropy to the domain of real numbers. Formula (*) is usually referred to as the '''continuous entropy''', or ]. Although the analogy between both functions is suggestive, the following question must be set: is the Boltzmann entropy a valid extension of the Shannon entropy? To answer this question, we must establish a connection between the two functions:


==Entropy for continuous random variables==
We wish to obtain a generally finite measure as the ] goes to zero. In the discrete case, the bin size is the (implicit) width of each of the ''n'' (finite or infinite) bins whose probabilities are denoted by ''p<sub>n</sub>''. As we generalize to the continuous domain, we must make this width explicit.


===Differential entropy===
To do this, start with a continuous function ''f'' discretized as shown in the figure.
{{Main|Differential entropy}}
<!-- Figure: Discretizing the function $ f$ into bins of width $ \Delta$
\includegraphics{function-with-bins.eps} -->
As the figure indicates, by the mean-value theorem there exists a value ''x<sub>i</sub>'' in each bin such that


The Shannon entropy is restricted to random variables taking discrete values. The corresponding formula for a continuous random variable with ] {{math|''f''(''x'')}} with finite or infinite support <math>\mathbb X</math> on the real line is defined by analogy, using the above form of the entropy as an expectation:<ref name=cover1991/>{{rp|224}}
:<math>f(x_i) \Delta = \int_{i\Delta}^{(i+1)\Delta} f(x)\, dx</math>


:<math>\Eta(X) = \mathbb{E} = -\int_\mathbb X f(x) \log f(x)\, \mathrm{d}x.</math>
and thus the integral of the function ''f'' can be approximated (in the Riemannian sense) by


This is the differential entropy (or continuous entropy). A precursor of the continuous entropy {{math|''h''}} is the expression for the functional {{math|''Η''}} in the ] of ].
:<math>\int_{-\infty}^{\infty} f(x)\, dx = \lim_{\Delta \to 0} \sum_{i = -\infty}^{\infty} f(x_i) \Delta</math>


Although the analogy between both functions is suggestive, the following question must be set: is the differential entropy a valid extension of the Shannon discrete entropy? Differential entropy lacks a number of properties that the Shannon discrete entropy has&nbsp;– it can even be negative&nbsp;– and corrections have been suggested, notably ].
where this limit and ''bin size goes to zero'' are equivalent.


To answer this question, a connection must be established between the two functions:
We will denote


In order to obtain a generally finite measure as the ] goes to zero. In the discrete case, the bin size is the (implicit) width of each of the {{math|''n''}} (finite or infinite) bins whose probabilities are denoted by {{math|''p''<sub>''n''</sub>}}. As the continuous domain is generalized, the width must be made explicit.
:<math>H^{\Delta} :=- \sum_{i=-\infty}^{\infty} \Delta f(x_i) \log \Delta f(x_i)</math>


To do this, start with a continuous function {{math|''f''}} discretized into bins of size <math>\Delta</math>.
<!-- Figure: Discretizing the function $ f$ into bins of width $ \Delta$ \includegraphics{function-with-bins.eps} --><!-- The original article this figure came from is at http://planetmath.org/shannonsentropy but it is broken there too -->
By the mean-value theorem there exists a value {{math|''x''<sub>''i''</sub>}} in each bin such that
<math display="block">f(x_i) \Delta = \int_{i\Delta}^{(i+1)\Delta} f(x)\, dx</math>
the integral of the function {{math|''f''}} can be approximated (in the Riemannian sense) by
<math display="block">\int_{-\infty}^{\infty} f(x)\, dx = \lim_{\Delta \to 0} \sum_{i = -\infty}^{\infty} f(x_i) \Delta ,</math>
where this limit and "bin size goes to zero" are equivalent.

We will denote
<math display="block">\Eta^{\Delta} := - \sum_{i=-\infty}^{\infty} f(x_i) \Delta \log \left( f(x_i) \Delta \right)</math>
and expanding the logarithm, we have and expanding the logarithm, we have
<math display="block">\Eta^{\Delta} = - \sum_{i=-\infty}^{\infty} f(x_i) \Delta \log (f(x_i)) -\sum_{i=-\infty}^{\infty} f(x_i) \Delta \log (\Delta).</math>


As {{math|Δ → 0}}, we have
:<math>H^{\Delta} = - \sum_{i=-\infty}^{\infty} \Delta f(x_i) \log \Delta f(x_i)</math>


:<math>\begin{align}
:<math> = - \sum_{i=-\infty}^{\infty} \Delta f(x_i) \log f(x_i) -\sum_{i=-\infty}^{\infty} f(x_i) \Delta \log \Delta.</math>
\sum_{i=-\infty}^{\infty} f(x_i) \Delta &\to \int_{-\infty}^{\infty} f(x)\, dx = 1 \\
\sum_{i=-\infty}^{\infty} f(x_i) \Delta \log (f(x_i)) &\to \int_{-\infty}^{\infty} f(x) \log f(x)\, dx.
\end{align}</math>


Note; {{math|log(Δ) → −∞}} as {{math|Δ → 0}}, requires a special definition of the differential or continuous entropy:
As <math>\Delta \to 0</math>, we have


:<math>\sum_{i=-\infty}^{\infty} f(x_i) \Delta \to \int f(x)\, dx = 1</math> :<math>h = \lim_{\Delta \to 0} \left(\Eta^{\Delta} + \log \Delta\right) = -\int_{-\infty}^{\infty} f(x) \log f(x)\,dx,</math>


which is, as said before, referred to as the differential entropy. This means that the differential entropy ''is not'' a limit of the Shannon entropy for {{math|''n'' → ∞}}. Rather, it differs from the limit of the Shannon entropy by an infinite offset (see also the article on ]).
and so


===Limiting density of discrete points===
:<math>\sum_{i=-\infty}^{\infty} \Delta f(x_i) \log f(x_i) \to \int f(x) \log f(x)\, dx.</math>
{{Main|Limiting density of discrete points}}


It turns out as a result that, unlike the Shannon entropy, the differential entropy is ''not'' in general a good measure of uncertainty or information. For example, the differential entropy can be negative; also it is not invariant under continuous co-ordinate transformations. This problem may be illustrated by a change of units when {{math|''x''}} is a dimensioned variable. {{math|''f''(''x'')}} will then have the units of {{math|1/''x''}}. The argument of the logarithm must be dimensionless, otherwise it is improper, so that the differential entropy as given above will be improper. If {{math|''&Delta;''}} is some "standard" value of {{math|''x''}} (i.e. "bin size") and therefore has the same units, then a modified differential entropy may be written in proper form as:
But note that <math>\log \Delta \to -\infty</math> as <math>\Delta \to 0</math>, therefore we need a special definition of the differential or continuous entropy:
:<math display="block">\Eta=\int_{-\infty}^\infty f(x) \log(f(x)\,\Delta)\,dx ,</math>
and the result will be the same for any choice of units for {{math|''x''}}. In fact, the limit of discrete entropy as <math> N \rightarrow \infty </math> would also include a term of <math> \log(N)</math>, which would in general be infinite. This is expected: continuous variables would typically have infinite entropy when discretized. The ] is really a measure of how much easier a distribution is to describe than a distribution that is uniform over its quantization scheme.


===Relative entropy===
:<math>h = \lim_{\Delta \to 0} \left = -\int_{-\infty}^{\infty} f(x) \log f(x)\,dx,</math>
{{main|Generalized relative entropy}}
Another useful measure of entropy that works equally well in the discrete and the continuous case is the '''relative entropy''' of a distribution. It is defined as the ] from the distribution to a reference measure {{math|''m''}} as follows. Assume that a probability distribution {{math|''p''}} is ] with respect to a measure {{math|''m''}}, i.e. is of the form {{math|''p''(''dx'') {{=}} ''f''(''x'')''m''(''dx'')}} for some non-negative {{math|''m''}}-integrable function {{math|''f''}} with {{math|''m''}}-integral 1, then the relative entropy can be defined as
:<math>D_{\mathrm{KL}}(p \| m ) = \int \log (f(x)) p(dx) = \int f(x)\log (f(x)) m(dx) .</math>


In this form the relative entropy generalizes (up to change in sign) both the discrete entropy, where the measure {{math|''m''}} is the ], and the differential entropy, where the measure {{math|''m''}} is the ]. If the measure {{math|''m''}} is itself a probability distribution, the relative entropy is non-negative, and zero if {{math|''p'' {{=}} ''m''}} as measures. It is defined for any measure space, hence coordinate independent and invariant under co-ordinate reparameterizations if one properly takes into account the transformation of the measure {{math|''m''}}. The relative entropy, and (implicitly) entropy and differential entropy, do depend on the "reference" measure {{math|''m''}}.
which is, as said before, referred to as the '''differential entropy'''. This means that the differential entropy ''is not'' a limit of the Shannon entropy for ''n'' &rarr; &infin;


==Use in number theory==
It turns out as a result that, unlike the Shannon entropy, the differential entropy is ''not'' in general a good measure of uncertainty or information. For example, the differential entropy can be negative; also it is not invariant under continuous co-ordinate transformations.
] used entropy to make a useful connection trying to solve the ].<ref>{{Cite web |last=Klarreich |first=Erica |author-link=Erica Klarreich |date=1 October 2015 |title=A Magical Answer to an 80-Year-Old Puzzle |url=https://www.quantamagazine.org/a-magical-answer-to-an-80-year-old-puzzle-20151001/ |access-date=18 August 2014 |website=]}}</ref><ref>{{Cite journal |last=Tao |first=Terence |date=2016-02-28 |title=The Erdős discrepancy problem |url=https://discreteanalysisjournal.com/article/609 |journal=Discrete Analysis |language=en |arxiv=1509.05363v6 |doi=10.19086/da.609 |s2cid=59361755 |access-date=20 September 2023 |archive-date=25 September 2023 |archive-url=https://web.archive.org/web/20230925184904/https://discreteanalysisjournal.com/article/609 |url-status=live }}</ref>


Intuitively the idea behind the proof was if there is low information in terms of the Shannon entropy between consecutive random variables (here the random variable is defined using the ] (which is a useful mathematical function for studying distribution of primes) {{math|''X''<sub>''H''</sub>}} {{=}} <math>\lambda(n+H)</math>. And in an interval the sum over that interval could become arbitrary large. For example, a sequence of +1's (which are values of {{math|''X''<sub>''H''</sub>}} could take) have trivially low entropy and their sum would become big. But the key insight was showing a reduction in entropy by non negligible amounts as one expands H leading inturn to unbounded growth of a mathematical object over this random variable is equivalent to showing the unbounded growth per the ].
More useful for the continuous case is the '''relative entropy''' of a distribution, defined as the ] from the distribution to a reference measure ''m''(''x''),

:<math>D_{\mathrm{KL}}(f(x)\|m(x)) = \int f(x)\log\frac{f(x)}{m(x)}\,dx</math>
The proof is quite involved and it brought together breakthroughs not just in novel use of Shannon Entropy, but also its used the ] along with {{Webarchive|url=https://web.archive.org/web/20231028111132/https://arxiv.org/pdf/1502.02374.pdf |date=28 October 2023 }} in short intervals. Proving it also broke the {{Webarchive|url=https://web.archive.org/web/20230807211237/https://terrytao.wordpress.com/2007/06/05/open-question-the-parity-problem-in-sieve-theory/ |date=7 August 2023 }} for this specific problem.
The relative entropy carries over directly from discrete to continuous distributions, and is invariant under co-ordinate reparametrisations.

While the use of Shannon Entropy in the proof is novel it is likely to open new research in this direction.

==Use in combinatorics==
Entropy has become a useful quantity in ].

===Loomis–Whitney inequality===
A simple example of this is an alternative proof of the ]: for every subset {{math|''A'' ⊆ '''Z'''<sup>''d''</sup>}}, we have
:<math> |A|^{d-1}\leq \prod_{i=1}^{d} |P_{i}(A)|</math>
where {{math|''P''<sub>''i''</sub>}} is the ] in the {{math|''i''}}th coordinate:
:<math> P_{i}(A)=\{(x_{1}, \ldots, x_{i-1}, x_{i+1}, \ldots, x_{d}) : (x_{1}, \ldots, x_{d})\in A\}.</math>

The proof follows as a simple corollary of ]: if {{math|''X''<sub>1</sub>, ..., ''X''<sub>''d''</sub>}} are random variables and {{math|''S''<sub>1</sub>, ..., ''S''<sub>''n''</sub>}} are subsets of {{math|{1, ..., ''d''}}} such that every integer between 1 and {{math|''d''}} lies in exactly {{math|''r''}} of these subsets, then
:<math> \Eta\leq \frac{1}{r}\sum_{i=1}^{n}\Eta</math>
where <math> (X_{j})_{j\in S_{i}}</math> is the Cartesian product of random variables {{math|''X''<sub>''j''</sub>}} with indexes {{math|''j''}} in {{math|''S''<sub>''i''</sub>}} (so the dimension of this vector is equal to the size of {{math|''S''<sub>''i''</sub>}}).

We sketch how Loomis–Whitney follows from this: Indeed, let {{math|''X''}} be a uniformly distributed random variable with values in {{math|''A''}} and so that each point in {{math|''A''}} occurs with equal probability. Then (by the further properties of entropy mentioned above) {{math|Η(''X'') {{=}} log{{abs|''A''}}}}, where {{math|{{abs|''A''}}}} denotes the cardinality of {{math|''A''}}. Let {{math|''S''<sub>''i''</sub> {{=}} {1, 2, ..., ''i''−1, ''i''+1, ..., ''d''}}}. The range of <math>(X_{j})_{j\in S_{i}}</math> is contained in {{math|''P''<sub>''i''</sub>(''A'')}} and hence <math> \Eta\leq \log |P_{i}(A)|</math>. Now use this to bound the right side of Shearer's inequality and exponentiate the opposite sides of the resulting inequality you obtain.

===Approximation to binomial coefficient===
For integers {{math|0 < ''k'' < ''n''}} let {{math|''q'' {{=}} ''k''/''n''}}. Then
:<math>\frac{2^{n\Eta(q)}}{n+1} \leq \tbinom nk \leq 2^{n\Eta(q)},</math>
where
:<math>\Eta(q) = -q \log_2(q) - (1-q) \log_2(1-q).</math><ref>Aoki, New Approaches to Macroeconomic Modeling.</ref>{{rp|43}}

:{| class="toccolours collapsible collapsed" width="80%" style="text-align:left"
!Proof (sketch)
|-
|Note that <math>\tbinom nk q^{qn}(1-q)^{n-nq}</math> is one term of the expression
:<math>\sum_{i=0}^n \tbinom ni q^i(1-q)^{n-i} = (q + (1-q))^n = 1.</math>
Rearranging gives the upper bound. For the lower bound one first shows, using some algebra, that it is the largest term in the summation. But then,
:<math>\binom nk q^{qn}(1-q)^{n-nq} \geq \frac{1}{n+1}</math>
since there are {{math|''n'' + 1}} terms in the summation. Rearranging gives the lower bound.
|}

A nice interpretation of this is that the number of binary strings of length {{math|''n''}} with exactly {{math|''k''}} many 1's is approximately <math>2^{n\Eta(k/n)}</math>.<ref>Probability and Computing, M. Mitzenmacher and E. Upfal, Cambridge University Press</ref>

== Use in machine learning ==
] techniques arise largely from statistics and also information theory. In general, entropy is a measure of uncertainty and the objective of machine learning is to minimize uncertainty.

] algorithms use relative entropy to determine the decision rules that govern the data at each node.<ref>{{Cite book|last1=Batra|first1=Mridula|last2=Agrawal|first2=Rashmi|title=Nature Inspired Computing|chapter=Comparative Analysis of Decision Tree Algorithms|date=2018|editor-last=Panigrahi|editor-first=Bijaya Ketan|editor2-last=Hoda|editor2-first=M. N.|editor3-last=Sharma|editor3-first=Vinod|editor4-last=Goel|editor4-first=Shivendra|chapter-url=https://link.springer.com/chapter/10.1007/978-981-10-6747-1_4|series=Advances in Intelligent Systems and Computing|volume=652|language=en|location=Singapore|publisher=Springer|pages=31–36|doi=10.1007/978-981-10-6747-1_4|isbn=978-981-10-6747-1|access-date=16 December 2021|archive-date=19 December 2022|archive-url=https://web.archive.org/web/20221219153239/https://link.springer.com/chapter/10.1007/978-981-10-6747-1_4|url-status=live}}</ref> The ] <math>IG(Y,X)</math>, which is equal to the difference between the entropy of <math>Y</math> and the conditional entropy of <math>Y</math> given <math>X</math>, quantifies the expected information, or the reduction in entropy, from additionally knowing the value of an attribute <math>X</math>. The information gain is used to identify which attributes of the dataset provide the most information and should be used to split the nodes of the tree optimally.

] models often apply the ] to obtain ] distributions.<ref>{{Cite journal|last=Jaynes|first=Edwin T.|date=September 1968|title=Prior Probabilities|url=https://ieeexplore.ieee.org/document/4082152|journal=IEEE Transactions on Systems Science and Cybernetics|volume=4|issue=3|pages=227–241|doi=10.1109/TSSC.1968.300117|issn=2168-2887|access-date=16 December 2021|archive-date=16 December 2021|archive-url=https://web.archive.org/web/20211216164659/https://ieeexplore.ieee.org/document/4082152|url-status=live}}</ref> The idea is that the distribution that best represents the current state of knowledge of a system is the one with the largest entropy, and is therefore suitable to be the prior.

] performed by ] or ]s often employs a standard loss function, called ] loss, that minimizes the average cross entropy between ground truth and predicted distributions.<ref>{{Cite book|last1=Rubinstein|first1=Reuven Y.|url=https://books.google.com/books?id=8KgACAAAQBAJ&dq=machine+learning+cross+entropy+loss+introduction&pg=PA1|title=The Cross-Entropy Method: A Unified Approach to Combinatorial Optimization, Monte-Carlo Simulation and Machine Learning|last2=Kroese|first2=Dirk P.|date=2013-03-09|publisher=Springer Science & Business Media|isbn=978-1-4757-4321-0|language=en}}</ref> In general, cross entropy is a measure of the differences between two datasets similar to the KL divergence (also known as relative entropy).

==See also==
{{Portal|Mathematics}}
{{colbegin}}
*] (ApEn)
*]
*] – is a measure of the average number of bits needed to identify an event from a set of possibilities between two probability distributions
*]
*] – a coding scheme that assigns codes to symbols so as to match code lengths with the probabilities of the symbols.
*]
*]
*]
*]
*]
*]
*]
*]
*]
*] in ]s
*]
*]
*]
*] – other measures of ] for ]
*] – a measure of distinguishability between two quantum states.
*] – a generalization of Shannon entropy; it is one of a family of functionals for quantifying the diversity, uncertainty or randomness of a system.
*]
*] (SampEn)
*]
*]
*]
{{colend}}

==Notes==
{{reflist|group=Note|refs=
<ref name=Note01>This definition allows events with probability 0, resulting in the undefined <math>\log(0)</math>. We do see <math>\lim\limits_{x\rightarrow0}x\log(x)=0</math> and it can be assumed that <math>0\log(0)</math> equals 0 in this context. Alternatively one can define <math>p\colon \mathcal{X}\to(0, 1]</math>, not allowing events with probability equal to exactly 0.</ref>
}}


==References== ==References==
{{Reflist}}
{{planetmath|id=968|title=Shannon's entropy}}
{{PlanetMath attribution|id=968|title=Shannon's entropy}}


== See also == ==Further reading==


===Textbooks on information theory===
* ]
* ], ] (2006), ''Elements of Information Theory – 2nd Ed.'', Wiley-Interscience, {{isbn|978-0-471-24195-9}}
* ]
* ] (2003), ''Information Theory, Inference and Learning Algorithms'', Cambridge University Press, {{isbn|978-0-521-64298-9}}
* ] in ]s
* Arndt, C. (2004), ''Information Measures: Information and its Description in Science and Engineering'', Springer, {{isbn|978-3-540-40855-0}}
* ]
* Gray, R. M. (2011), ''Entropy and Information Theory'', Springer.
* ]
* {{cite book|author1=Martin, Nathaniel F.G. |author2=England, James W. |title=Mathematical Theory of Entropy|publisher=Cambridge University Press|year=2011|isbn=978-0-521-17738-2|url=https://books.google.com/books?id=_77lvx7y8joC}}
* ]
* ], ] (1949) ''The Mathematical Theory of Communication'', Univ of Illinois Press. {{isbn|0-252-72548-4}}
* Stone, J. V. (2014), Chapter 1 of {{Webarchive|url=https://web.archive.org/web/20160603070027/http://jim-stone.staff.shef.ac.uk/BookInfoTheory/InfoTheoryBookMain.html |date=3 June 2016 }}, University of Sheffield, England. {{isbn|978-0956372857}}.


== External links == ==External links==
{{Wikibooks|An Intuitive Guide to the Concept of Entropy Arising in Various Sectors of Science}}
{{Library resources box|onlinebooks=yes}}
* {{springer|title=Entropy|id=p/e035740}}
* {{Webarchive|url=https://web.archive.org/web/20160604053728/http://rosettacode.org/Entropy |date=4 June 2016 }} at ]—repository of implementations of Shannon entropy in different programming languages.
* '' {{Webarchive|url=https://web.archive.org/web/20160531032753/http://www.mdpi.com/journal/entropy |date=31 May 2016 }}'' an interdisciplinary journal on all aspects of the entropy concept. Open access.


{{Compression Methods}}
* - a discussion of the use of the terms "information" and "entropy".
{{Authority control}}
* - a similar discussion on the bionet.info-theory FAQ.
*
*


] ]
] ]
] ]
] ]
]

]
]
]
]
]
]
]
]
]
]
]
]
]

Latest revision as of 23:56, 5 December 2024

Expected amount of information needed to specify the output of a stochastic data source For other uses, see Entropy (disambiguation).
This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Entropy" information theory – news · newspapers · books · scholar · JSTOR (February 2019) (Learn how and when to remove this message)

Information theory

In information theory, the entropy of a random variable quantifies the average level of uncertainty or information associated with the variable's potential states or possible outcomes. This measures the expected amount of information needed to describe the state of the variable, considering the distribution of probabilities across all potential states. Given a discrete random variable X {\displaystyle X} , which takes values in the set X {\displaystyle {\mathcal {X}}} and is distributed according to p : X [ 0 , 1 ] {\displaystyle p\colon {\mathcal {X}}\to } , the entropy is H ( X ) := x X p ( x ) log p ( x ) , {\displaystyle \mathrm {H} (X):=-\sum _{x\in {\mathcal {X}}}p(x)\log p(x),} where Σ {\displaystyle \Sigma } denotes the sum over the variable's possible values. The choice of base for log {\displaystyle \log } , the logarithm, varies for different applications. Base 2 gives the unit of bits (or "shannons"), while base e gives "natural units" nat, and base 10 gives units of "dits", "bans", or "hartleys". An equivalent definition of entropy is the expected value of the self-information of a variable.

Two bits of entropy: In the case of two fair coin tosses, the information entropy in bits is the base-2 logarithm of the number of possible outcomes‍— with two coins there are four possible outcomes, and two bits of entropy. Generally, information entropy is the average amount of information conveyed by an event, when considering all possible outcomes.

The concept of information entropy was introduced by Claude Shannon in his 1948 paper "A Mathematical Theory of Communication", and is also referred to as Shannon entropy. Shannon's theory defines a data communication system composed of three elements: a source of data, a communication channel, and a receiver. The "fundamental problem of communication" – as expressed by Shannon – is for the receiver to be able to identify what data was generated by the source, based on the signal it receives through the channel. Shannon considered various ways to encode, compress, and transmit messages from a data source, and proved in his source coding theorem that the entropy represents an absolute mathematical limit on how well data from the source can be losslessly compressed onto a perfectly noiseless channel. Shannon strengthened this result considerably for noisy channels in his noisy-channel coding theorem.

Entropy in information theory is directly analogous to the entropy in statistical thermodynamics. The analogy results when the values of the random variable designate energies of microstates, so Gibbs's formula for the entropy is formally identical to Shannon's formula. Entropy has relevance to other areas of mathematics such as combinatorics and machine learning. The definition can be derived from a set of axioms establishing that entropy should be a measure of how informative the average outcome of a variable is. For a continuous random variable, differential entropy is analogous to entropy. The definition E [ log p ( X ) ] {\displaystyle \mathbb {E} } generalizes the above.

Introduction

The core idea of information theory is that the "informational value" of a communicated message depends on the degree to which the content of the message is surprising. If a highly likely event occurs, the message carries very little information. On the other hand, if a highly unlikely event occurs, the message is much more informative. For instance, the knowledge that some particular number will not be the winning number of a lottery provides very little information, because any particular chosen number will almost certainly not win. However, knowledge that a particular number will win a lottery has high informational value because it communicates the occurrence of a very low probability event.

The information content, also called the surprisal or self-information, of an event E {\displaystyle E} is a function that increases as the probability p ( E ) {\displaystyle p(E)} of an event decreases. When p ( E ) {\displaystyle p(E)} is close to 1, the surprisal of the event is low, but if p ( E ) {\displaystyle p(E)} is close to 0, the surprisal of the event is high. This relationship is described by the function log ( 1 p ( E ) ) , {\displaystyle \log \left({\frac {1}{p(E)}}\right),} where log {\displaystyle \log } is the logarithm, which gives 0 surprise when the probability of the event is 1. In fact, log is the only function that satisfies а specific set of conditions defined in section § Characterization.

Hence, we can define the information, or surprisal, of an event E {\displaystyle E} by I ( E ) = log 2 ( p ( E ) ) , {\displaystyle I(E)=-\log _{2}(p(E)),} or equivalently, I ( E ) = log 2 ( 1 p ( E ) ) . {\displaystyle I(E)=\log _{2}\left({\frac {1}{p(E)}}\right).}

Entropy measures the expected (i.e., average) amount of information conveyed by identifying the outcome of a random trial. This implies that rolling a die has higher entropy than tossing a coin because each outcome of a die toss has smaller probability ( p = 1 / 6 {\displaystyle p=1/6} ) than each outcome of a coin toss ( p = 1 / 2 {\displaystyle p=1/2} ).

Consider a coin with probability p of landing on heads and probability 1 − p of landing on tails. The maximum surprise is when p = 1/2, for which one outcome is not expected over the other. In this case a coin flip has an entropy of one bit. (Similarly, one trit with equiprobable values contains log 2 3 {\displaystyle \log _{2}3} (about 1.58496) bits of information because it can have one of three values.) The minimum surprise is when p = 0 or p = 1, when the event outcome is known ahead of time, and the entropy is zero bits. When the entropy is zero bits, this is sometimes referred to as unity, where there is no uncertainty at all – no freedom of choice – no information. Other values of p give entropies between zero and one bits.

Example

Information theory is useful to calculate the smallest amount of information required to convey a message, as in data compression. For example, consider the transmission of sequences comprising the 4 characters 'A', 'B', 'C', and 'D' over a binary channel. If all 4 letters are equally likely (25%), one cannot do better than using two bits to encode each letter. 'A' might code as '00', 'B' as '01', 'C' as '10', and 'D' as '11'. However, if the probabilities of each letter are unequal, say 'A' occurs with 70% probability, 'B' with 26%, and 'C' and 'D' with 2% each, one could assign variable length codes. In this case, 'A' would be coded as '0', 'B' as '10', 'C' as '110', and 'D' as '111'. With this representation, 70% of the time only one bit needs to be sent, 26% of the time two bits, and only 4% of the time 3 bits. On average, fewer than 2 bits are required since the entropy is lower (owing to the high prevalence of 'A' followed by 'B' – together 96% of characters). The calculation of the sum of probability-weighted log probabilities measures and captures this effect.

English text, treated as a string of characters, has fairly low entropy; i.e. it is fairly predictable. We can be fairly certain that, for example, 'e' will be far more common than 'z', that the combination 'qu' will be much more common than any other combination with a 'q' in it, and that the combination 'th' will be more common than 'z', 'q', or 'qu'. After the first few letters one can often guess the rest of the word. English text has between 0.6 and 1.3 bits of entropy per character of the message.

Definition

Named after Boltzmann's Η-theorem, Shannon defined the entropy Η (Greek capital letter eta) of a discrete random variable X {\textstyle X} , which takes values in the set X {\displaystyle {\mathcal {X}}} and is distributed according to p : X [ 0 , 1 ] {\displaystyle p:{\mathcal {X}}\to } such that p ( x ) := P [ X = x ] {\displaystyle p(x):=\mathbb {P} } :

H ( X ) = E [ I ( X ) ] = E [ log p ( X ) ] . {\displaystyle \mathrm {H} (X)=\mathbb {E} =\mathbb {E} .}

Here E {\displaystyle \mathbb {E} } is the expected value operator, and I is the information content of X. I ( X ) {\displaystyle \operatorname {I} (X)} is itself a random variable.

The entropy can explicitly be written as: H ( X ) = x X p ( x ) log b p ( x ) , {\displaystyle \mathrm {H} (X)=-\sum _{x\in {\mathcal {X}}}p(x)\log _{b}p(x),} where b is the base of the logarithm used. Common values of b are 2, Euler's number e, and 10, and the corresponding units of entropy are the bits for b = 2, nats for b = e, and bans for b = 10.

In the case of p ( x ) = 0 {\displaystyle p(x)=0} for some x X {\displaystyle x\in {\mathcal {X}}} , the value of the corresponding summand 0 logb(0) is taken to be 0, which is consistent with the limit: lim p 0 + p log ( p ) = 0. {\displaystyle \lim _{p\to 0^{+}}p\log(p)=0.}

One may also define the conditional entropy of two variables X {\displaystyle X} and Y {\displaystyle Y} taking values from sets X {\displaystyle {\mathcal {X}}} and Y {\displaystyle {\mathcal {Y}}} respectively, as: H ( X | Y ) = x , y X × Y p X , Y ( x , y ) log p X , Y ( x , y ) p Y ( y ) , {\displaystyle \mathrm {H} (X|Y)=-\sum _{x,y\in {\mathcal {X}}\times {\mathcal {Y}}}p_{X,Y}(x,y)\log {\frac {p_{X,Y}(x,y)}{p_{Y}(y)}},} where p X , Y ( x , y ) := P [ X = x , Y = y ] {\displaystyle p_{X,Y}(x,y):=\mathbb {P} } and p Y ( y ) = P [ Y = y ] {\displaystyle p_{Y}(y)=\mathbb {P} } . This quantity should be understood as the remaining randomness in the random variable X {\displaystyle X} given the random variable Y {\displaystyle Y} .

Measure theory

Entropy can be formally defined in the language of measure theory as follows: Let ( X , Σ , μ ) {\displaystyle (X,\Sigma ,\mu )} be a probability space. Let A Σ {\displaystyle A\in \Sigma } be an event. The surprisal of A {\displaystyle A} is σ μ ( A ) = ln μ ( A ) . {\displaystyle \sigma _{\mu }(A)=-\ln \mu (A).}

The expected surprisal of A {\displaystyle A} is h μ ( A ) = μ ( A ) σ μ ( A ) . {\displaystyle h_{\mu }(A)=\mu (A)\sigma _{\mu }(A).}

A μ {\displaystyle \mu } -almost partition is a set family P P ( X ) {\displaystyle P\subseteq {\mathcal {P}}(X)} such that μ ( P ) = 1 {\displaystyle \mu (\mathop {\cup } P)=1} and μ ( A B ) = 0 {\displaystyle \mu (A\cap B)=0} for all distinct A , B P {\displaystyle A,B\in P} . (This is a relaxation of the usual conditions for a partition.) The entropy of P {\displaystyle P} is H μ ( P ) = A P h μ ( A ) . {\displaystyle \mathrm {H} _{\mu }(P)=\sum _{A\in P}h_{\mu }(A).}

Let M {\displaystyle M} be a sigma-algebra on X {\displaystyle X} . The entropy of M {\displaystyle M} is H μ ( M ) = sup P M H μ ( P ) . {\displaystyle \mathrm {H} _{\mu }(M)=\sup _{P\subseteq M}\mathrm {H} _{\mu }(P).} Finally, the entropy of the probability space is H μ ( Σ ) {\displaystyle \mathrm {H} _{\mu }(\Sigma )} , that is, the entropy with respect to μ {\displaystyle \mu } of the sigma-algebra of all measurable subsets of X {\displaystyle X} .

Example

Entropy Η(X) (i.e. the expected surprisal) of a coin flip, measured in bits, graphed versus the bias of the coin Pr(X = 1), where X = 1 represents a result of heads.

Here, the entropy is at most 1 bit, and to communicate the outcome of a coin flip (2 possible values) will require an average of at most 1 bit (exactly 1 bit for a fair coin). The result of a fair die (6 possible values) would have entropy log26 bits.
Main articles: Binary entropy function and Bernoulli process

Consider tossing a coin with known, not necessarily fair, probabilities of coming up heads or tails; this can be modeled as a Bernoulli process.

The entropy of the unknown result of the next toss of the coin is maximized if the coin is fair (that is, if heads and tails both have equal probability 1/2). This is the situation of maximum uncertainty as it is most difficult to predict the outcome of the next toss; the result of each toss of the coin delivers one full bit of information. This is because H ( X ) = i = 1 n p ( x i ) log b p ( x i ) = i = 1 2 1 2 log 2 1 2 = i = 1 2 1 2 ( 1 ) = 1. {\displaystyle {\begin{aligned}\mathrm {H} (X)&=-\sum _{i=1}^{n}{p(x_{i})\log _{b}p(x_{i})}\\&=-\sum _{i=1}^{2}{{\frac {1}{2}}\log _{2}{\frac {1}{2}}}\\&=-\sum _{i=1}^{2}{{\frac {1}{2}}\cdot (-1)}=1.\end{aligned}}}

However, if we know the coin is not fair, but comes up heads or tails with probabilities p and q, where pq, then there is less uncertainty. Every time it is tossed, one side is more likely to come up than the other. The reduced uncertainty is quantified in a lower entropy: on average each toss of the coin delivers less than one full bit of information. For example, if p = 0.7, then H ( X ) = p log 2 ( p ) q log 2 ( q ) = 0.7 log 2 ( 0.7 ) 0.3 log 2 ( 0.3 ) 0.7 ( 0.515 ) 0.3 ( 1.737 ) = 0.8816 < 1. {\displaystyle {\begin{aligned}\mathrm {H} (X)&=-p\log _{2}(p)-q\log _{2}(q)\\&=-0.7\log _{2}(0.7)-0.3\log _{2}(0.3)\\&\approx -0.7\cdot (-0.515)-0.3\cdot (-1.737)\\&=0.8816<1.\end{aligned}}}

Uniform probability yields maximum uncertainty and therefore maximum entropy. Entropy, then, can only decrease from the value associated with uniform probability. The extreme case is that of a double-headed coin that never comes up tails, or a double-tailed coin that never results in a head. Then there is no uncertainty. The entropy is zero: each toss of the coin delivers no new information as the outcome of each coin toss is always certain.

Characterization

To understand the meaning of −Σ pi log(pi), first define an information function I in terms of an event i with probability pi. The amount of information acquired due to the observation of event i follows from Shannon's solution of the fundamental properties of information:

  1. I(p) is monotonically decreasing in p: an increase in the probability of an event decreases the information from an observed event, and vice versa.
  2. I(1) = 0: events that always occur do not communicate information.
  3. I(p1·p2) = I(p1) + I(p2): the information learned from independent events is the sum of the information learned from each event.

Given two independent events, if the first event can yield one of n equiprobable outcomes and another has one of m equiprobable outcomes then there are mn equiprobable outcomes of the joint event. This means that if log2(n) bits are needed to encode the first value and log2(m) to encode the second, one needs log2(mn) = log2(m) + log2(n) to encode both.

Shannon discovered that a suitable choice of I {\displaystyle \operatorname {I} } is given by: I ( p ) = log ( 1 p ) = log ( p ) . {\displaystyle \operatorname {I} (p)=\log \left({\tfrac {1}{p}}\right)=-\log(p).}

In fact, the only possible values of I {\displaystyle \operatorname {I} } are I ( u ) = k log u {\displaystyle \operatorname {I} (u)=k\log u} for k < 0 {\displaystyle k<0} . Additionally, choosing a value for k is equivalent to choosing a value x > 1 {\displaystyle x>1} for k = 1 / log x {\displaystyle k=-1/\log x} , so that x corresponds to the base for the logarithm. Thus, entropy is characterized by the above four properties.

Proof
Let I {\textstyle \operatorname {I} } be the information function which one assumes to be twice continuously differentiable, one has:
I ( p 1 p 2 ) =   I ( p 1 ) + I ( p 2 ) Starting from property 3 p 2 I ( p 1 p 2 ) =   I ( p 1 ) taking the derivative w.r.t   p 1 I ( p 1 p 2 ) + p 1 p 2 I ( p 1 p 2 ) =   0 taking the derivative w.r.t   p 2 I ( u ) + u I ( u ) =   0 introducing u = p 1 p 2 ( u I ( u ) ) =   0 combining terms into one   u I ( u ) k =   0 integrating w.r.t   u , producing constant k {\displaystyle {\begin{aligned}&\operatorname {I} (p_{1}p_{2})&=\ &\operatorname {I} (p_{1})+\operatorname {I} (p_{2})&&\quad {\text{Starting from property 3}}\\&p_{2}\operatorname {I} '(p_{1}p_{2})&=\ &\operatorname {I} '(p_{1})&&\quad {\text{taking the derivative w.r.t}}\ p_{1}\\&\operatorname {I} '(p_{1}p_{2})+p_{1}p_{2}\operatorname {I} ''(p_{1}p_{2})&=\ &0&&\quad {\text{taking the derivative w.r.t}}\ p_{2}\\&\operatorname {I} '(u)+u\operatorname {I} ''(u)&=\ &0&&\quad {\text{introducing}}\,u=p_{1}p_{2}\\&(u\operatorname {I} '(u))'&=\ &0&&\quad {\text{combining terms into one}}\ \\&u\operatorname {I} '(u)-k&=\ &0&&\quad {\text{integrating w.r.t}}\ u,{\text{producing constant}}\,k\\\end{aligned}}}

This differential equation leads to the solution I ( u ) = k log u + c {\displaystyle \operatorname {I} (u)=k\log u+c} for some k , c R {\displaystyle k,c\in \mathbb {R} } . Property 2 gives c = 0 {\displaystyle c=0} . Property 1 and 2 give that I ( p ) 0 {\displaystyle \operatorname {I} (p)\geq 0} for all p [ 0 , 1 ] {\displaystyle p\in } , so that k < 0 {\displaystyle k<0} .

The different units of information (bits for the binary logarithm log2, nats for the natural logarithm ln, bans for the decimal logarithm log10 and so on) are constant multiples of each other. For instance, in case of a fair coin toss, heads provides log2(2) = 1 bit of information, which is approximately 0.693 nats or 0.301 decimal digits. Because of additivity, n tosses provide n bits of information, which is approximately 0.693n nats or 0.301n decimal digits.

The meaning of the events observed (the meaning of messages) does not matter in the definition of entropy. Entropy only takes into account the probability of observing a specific event, so the information it encapsulates is information about the underlying probability distribution, not the meaning of the events themselves.

Alternative characterization

Another characterization of entropy uses the following properties. We denote pi = Pr(X = xi) and Ηn(p1, ..., pn) = Η(X).

  1. Continuity: H should be continuous, so that changing the values of the probabilities by a very small amount should only change the entropy by a small amount.
  2. Symmetry: H should be unchanged if the outcomes xi are re-ordered. That is, H n ( p 1 , p 2 , p n ) = H n ( p i 1 , p i 2 , , p i n ) {\displaystyle \mathrm {H} _{n}\left(p_{1},p_{2},\ldots p_{n}\right)=\mathrm {H} _{n}\left(p_{i_{1}},p_{i_{2}},\ldots ,p_{i_{n}}\right)} for any permutation { i 1 , . . . , i n } {\displaystyle \{i_{1},...,i_{n}\}} of { 1 , . . . , n } {\displaystyle \{1,...,n\}} .
  3. Maximum: H n {\displaystyle \mathrm {H} _{n}} should be maximal if all the outcomes are equally likely i.e. H n ( p 1 , , p n ) H n ( 1 n , , 1 n ) {\displaystyle \mathrm {H} _{n}(p_{1},\ldots ,p_{n})\leq \mathrm {H} _{n}\left({\frac {1}{n}},\ldots ,{\frac {1}{n}}\right)} .
  4. Increasing number of outcomes: for equiprobable events, the entropy should increase with the number of outcomes i.e. H n ( 1 n , , 1 n n ) < H n + 1 ( 1 n + 1 , , 1 n + 1 n + 1 ) . {\displaystyle \mathrm {H} _{n}{\bigg (}\underbrace {{\frac {1}{n}},\ldots ,{\frac {1}{n}}} _{n}{\bigg )}<\mathrm {H} _{n+1}{\bigg (}\underbrace {{\frac {1}{n+1}},\ldots ,{\frac {1}{n+1}}} _{n+1}{\bigg )}.}
  5. Additivity: given an ensemble of n uniformly distributed elements that are partitioned into k boxes (sub-systems) with b1, ..., bk elements each, the entropy of the whole ensemble should be equal to the sum of the entropy of the system of boxes and the individual entropies of the boxes, each weighted with the probability of being in that particular box.

Discussion

The rule of additivity has the following consequences: for positive integers bi where b1 + ... + bk = n,

H n ( 1 n , , 1 n ) = H k ( b 1 n , , b k n ) + i = 1 k b i n H b i ( 1 b i , , 1 b i ) . {\displaystyle \mathrm {H} _{n}\left({\frac {1}{n}},\ldots ,{\frac {1}{n}}\right)=\mathrm {H} _{k}\left({\frac {b_{1}}{n}},\ldots ,{\frac {b_{k}}{n}}\right)+\sum _{i=1}^{k}{\frac {b_{i}}{n}}\,\mathrm {H} _{b_{i}}\left({\frac {1}{b_{i}}},\ldots ,{\frac {1}{b_{i}}}\right).}

Choosing k = n, b1 = ... = bn = 1 this implies that the entropy of a certain outcome is zero: Η1(1) = 0. This implies that the efficiency of a source set with n symbols can be defined simply as being equal to its n-ary entropy. See also Redundancy (information theory).

The characterization here imposes an additive property with respect to a partition of a set. Meanwhile, the conditional probability is defined in terms of a multiplicative property, P ( A B ) P ( B ) = P ( A B ) {\displaystyle P(A\mid B)\cdot P(B)=P(A\cap B)} . Observe that a logarithm mediates between these two operations. The conditional entropy and related quantities inherit simple relation, in turn. The measure theoretic definition in the previous section defined the entropy as a sum over expected surprisals μ ( A ) ln μ ( A ) {\displaystyle \mu (A)\cdot \ln \mu (A)} for an extremal partition. Here the logarithm is ad hoc and the entropy is not a measure in itself. At least in the information theory of a binary string, log 2 {\displaystyle \log _{2}} lends itself to practical interpretations.

Motivated by such relations, a plethora of related and competing quantities have been defined. For example, David Ellerman's analysis of a "logic of partitions" defines a competing measure in structures dual to that of subsets of a universal set. Information is quantified as "dits" (distinctions), a measure on partitions. "Dits" can be converted into Shannon's bits, to get the formulas for conditional entropy, and so on.

Alternative characterization via additivity and subadditivity

Another succinct axiomatic characterization of Shannon entropy was given by Aczél, Forte and Ng, via the following properties:

  1. Subadditivity: H ( X , Y ) H ( X ) + H ( Y ) {\displaystyle \mathrm {H} (X,Y)\leq \mathrm {H} (X)+\mathrm {H} (Y)} for jointly distributed random variables X , Y {\displaystyle X,Y} .
  2. Additivity: H ( X , Y ) = H ( X ) + H ( Y ) {\displaystyle \mathrm {H} (X,Y)=\mathrm {H} (X)+\mathrm {H} (Y)} when the random variables X , Y {\displaystyle X,Y} are independent.
  3. Expansibility: H n + 1 ( p 1 , , p n , 0 ) = H n ( p 1 , , p n ) {\displaystyle \mathrm {H} _{n+1}(p_{1},\ldots ,p_{n},0)=\mathrm {H} _{n}(p_{1},\ldots ,p_{n})} , i.e., adding an outcome with probability zero does not change the entropy.
  4. Symmetry: H n ( p 1 , , p n ) {\displaystyle \mathrm {H} _{n}(p_{1},\ldots ,p_{n})} is invariant under permutation of p 1 , , p n {\displaystyle p_{1},\ldots ,p_{n}} .
  5. Small for small probabilities: lim q 0 + H 2 ( 1 q , q ) = 0 {\displaystyle \lim _{q\to 0^{+}}\mathrm {H} _{2}(1-q,q)=0} .

Discussion

It was shown that any function H {\displaystyle \mathrm {H} } satisfying the above properties must be a constant multiple of Shannon entropy, with a non-negative constant. Compared to the previously mentioned characterizations of entropy, this characterization focuses on the properties of entropy as a function of random variables (subadditivity and additivity), rather than the properties of entropy as a function of the probability vector p 1 , , p n {\displaystyle p_{1},\ldots ,p_{n}} .

It is worth noting that if we drop the "small for small probabilities" property, then H {\displaystyle \mathrm {H} } must be a non-negative linear combination of the Shannon entropy and the Hartley entropy.

Further properties

The Shannon entropy satisfies the following properties, for some of which it is useful to interpret entropy as the expected amount of information learned (or uncertainty eliminated) by revealing the value of a random variable X:

  • Adding or removing an event with probability zero does not contribute to the entropy:
H n + 1 ( p 1 , , p n , 0 ) = H n ( p 1 , , p n ) {\displaystyle \mathrm {H} _{n+1}(p_{1},\ldots ,p_{n},0)=\mathrm {H} _{n}(p_{1},\ldots ,p_{n})} .
  • The maximal entropy of an event with n different outcomes is logb(n): it is attained by the uniform probability distribution. That is, uncertainty is maximal when all possible events are equiprobable:
H ( p 1 , , p n ) log b n {\displaystyle \mathrm {H} (p_{1},\dots ,p_{n})\leq \log _{b}n} .
  • The entropy or the amount of information revealed by evaluating (X,Y) (that is, evaluating X and Y simultaneously) is equal to the information revealed by conducting two consecutive experiments: first evaluating the value of Y, then revealing the value of X given that you know the value of Y. This may be written as:
H ( X , Y ) = H ( X | Y ) + H ( Y ) = H ( Y | X ) + H ( X ) . {\displaystyle \mathrm {H} (X,Y)=\mathrm {H} (X|Y)+\mathrm {H} (Y)=\mathrm {H} (Y|X)+\mathrm {H} (X).}
  • If Y = f ( X ) {\displaystyle Y=f(X)} where f {\displaystyle f} is a function, then H ( f ( X ) | X ) = 0 {\displaystyle \mathrm {H} (f(X)|X)=0} . Applying the previous formula to H ( X , f ( X ) ) {\displaystyle \mathrm {H} (X,f(X))} yields
H ( X ) + H ( f ( X ) | X ) = H ( f ( X ) ) + H ( X | f ( X ) ) , {\displaystyle \mathrm {H} (X)+\mathrm {H} (f(X)|X)=\mathrm {H} (f(X))+\mathrm {H} (X|f(X)),}
so H ( f ( X ) ) H ( X ) {\displaystyle \mathrm {H} (f(X))\leq \mathrm {H} (X)} , the entropy of a variable can only decrease when the latter is passed through a function.
  • If X and Y are two independent random variables, then knowing the value of Y doesn't influence our knowledge of the value of X (since the two don't influence each other by independence):
H ( X | Y ) = H ( X ) . {\displaystyle \mathrm {H} (X|Y)=\mathrm {H} (X).}
  • More generally, for any random variables X and Y, we have
H ( X | Y ) H ( X ) {\displaystyle \mathrm {H} (X|Y)\leq \mathrm {H} (X)} .
  • The entropy of two simultaneous events is no more than the sum of the entropies of each individual event i.e., H ( X , Y ) H ( X ) + H ( Y ) {\displaystyle \mathrm {H} (X,Y)\leq \mathrm {H} (X)+\mathrm {H} (Y)} , with equality if and only if the two events are independent.
  • The entropy H ( p ) {\displaystyle \mathrm {H} (p)} is concave in the probability mass function p {\displaystyle p} , i.e.
H ( λ p 1 + ( 1 λ ) p 2 ) λ H ( p 1 ) + ( 1 λ ) H ( p 2 ) {\displaystyle \mathrm {H} (\lambda p_{1}+(1-\lambda )p_{2})\geq \lambda \mathrm {H} (p_{1})+(1-\lambda )\mathrm {H} (p_{2})}
for all probability mass functions p 1 , p 2 {\displaystyle p_{1},p_{2}} and 0 λ 1 {\displaystyle 0\leq \lambda \leq 1} .

Aspects

Relationship to thermodynamic entropy

Main article: Entropy in thermodynamics and information theory

The inspiration for adopting the word entropy in information theory came from the close resemblance between Shannon's formula and very similar known formulae from statistical mechanics.

In statistical thermodynamics the most general formula for the thermodynamic entropy S of a thermodynamic system is the Gibbs entropy

S = k B p i ln p i , {\displaystyle S=-k_{\text{B}}\sum p_{i}\ln p_{i}\,,}

where kB is the Boltzmann constant, and pi is the probability of a microstate. The Gibbs entropy was defined by J. Willard Gibbs in 1878 after earlier work by Boltzmann (1872).

The Gibbs entropy translates over almost unchanged into the world of quantum physics to give the von Neumann entropy introduced by John von Neumann in 1927:

S = k B T r ( ρ ln ρ ) , {\displaystyle S=-k_{\text{B}}\,{\rm {Tr}}(\rho \ln \rho )\,,}

where ρ is the density matrix of the quantum mechanical system and Tr is the trace.

At an everyday practical level, the links between information entropy and thermodynamic entropy are not evident. Physicists and chemists are apt to be more interested in changes in entropy as a system spontaneously evolves away from its initial conditions, in accordance with the second law of thermodynamics, rather than an unchanging probability distribution. As the minuteness of the Boltzmann constant kB indicates, the changes in S / kB for even tiny amounts of substances in chemical and physical processes represent amounts of entropy that are extremely large compared to anything in data compression or signal processing. In classical thermodynamics, entropy is defined in terms of macroscopic measurements and makes no reference to any probability distribution, which is central to the definition of information entropy.

The connection between thermodynamics and what is now known as information theory was first made by Ludwig Boltzmann and expressed by his equation:

S = k B ln W , {\displaystyle S=k_{\text{B}}\ln W,}

where S {\displaystyle S} is the thermodynamic entropy of a particular macrostate (defined by thermodynamic parameters such as temperature, volume, energy, etc.), W is the number of microstates (various combinations of particles in various energy states) that can yield the given macrostate, and kB is the Boltzmann constant. It is assumed that each microstate is equally likely, so that the probability of a given microstate is pi = 1/W. When these probabilities are substituted into the above expression for the Gibbs entropy (or equivalently kB times the Shannon entropy), Boltzmann's equation results. In information theoretic terms, the information entropy of a system is the amount of "missing" information needed to determine a microstate, given the macrostate.

In the view of Jaynes (1957), thermodynamic entropy, as explained by statistical mechanics, should be seen as an application of Shannon's information theory: the thermodynamic entropy is interpreted as being proportional to the amount of further Shannon information needed to define the detailed microscopic state of the system, that remains uncommunicated by a description solely in terms of the macroscopic variables of classical thermodynamics, with the constant of proportionality being just the Boltzmann constant. Adding heat to a system increases its thermodynamic entropy because it increases the number of possible microscopic states of the system that are consistent with the measurable values of its macroscopic variables, making any complete state description longer. (See article: maximum entropy thermodynamics). Maxwell's demon can (hypothetically) reduce the thermodynamic entropy of a system by using information about the states of individual molecules; but, as Landauer (from 1961) and co-workers have shown, to function the demon himself must increase thermodynamic entropy in the process, by at least the amount of Shannon information he proposes to first acquire and store; and so the total thermodynamic entropy does not decrease (which resolves the paradox). Landauer's principle imposes a lower bound on the amount of heat a computer must generate to process a given amount of information, though modern computers are far less efficient.

Data compression

Main articles: Shannon's source coding theorem and Data compression

Shannon's definition of entropy, when applied to an information source, can determine the minimum channel capacity required to reliably transmit the source as encoded binary digits. Shannon's entropy measures the information contained in a message as opposed to the portion of the message that is determined (or predictable). Examples of the latter include redundancy in language structure or statistical properties relating to the occurrence frequencies of letter or word pairs, triplets etc. The minimum channel capacity can be realized in theory by using the typical set or in practice using Huffman, Lempel–Ziv or arithmetic coding. (See also Kolmogorov complexity.) In practice, compression algorithms deliberately include some judicious redundancy in the form of checksums to protect against errors. The entropy rate of a data source is the average number of bits per symbol needed to encode it. Shannon's experiments with human predictors show an information rate between 0.6 and 1.3 bits per character in English; the PPM compression algorithm can achieve a compression ratio of 1.5 bits per character in English text.

If a compression scheme is lossless – one in which you can always recover the entire original message by decompression – then a compressed message has the same quantity of information as the original but is communicated in fewer characters. It has more information (higher entropy) per character. A compressed message has less redundancy. Shannon's source coding theorem states a lossless compression scheme cannot compress messages, on average, to have more than one bit of information per bit of message, but that any value less than one bit of information per bit of message can be attained by employing a suitable coding scheme. The entropy of a message per bit multiplied by the length of that message is a measure of how much total information the message contains. Shannon's theorem also implies that no lossless compression scheme can shorten all messages. If some messages come out shorter, at least one must come out longer due to the pigeonhole principle. In practical use, this is generally not a problem, because one is usually only interested in compressing certain types of messages, such as a document in English, as opposed to gibberish text, or digital photographs rather than noise, and it is unimportant if a compression algorithm makes some unlikely or uninteresting sequences larger.

A 2011 study in Science estimates the world's technological capacity to store and communicate optimally compressed information normalized on the most effective compression algorithms available in the year 2007, therefore estimating the entropy of the technologically available sources.

All figures in entropically compressed exabytes
Type of Information 1986 2007
Storage 2.6 295
Broadcast 432 1900
Telecommunications 0.281 65

The authors estimate humankind technological capacity to store information (fully entropically compressed) in 1986 and again in 2007. They break the information into three categories—to store information on a medium, to receive information through one-way broadcast networks, or to exchange information through two-way telecommunications networks.

Entropy as a measure of diversity

Main article: Diversity index

Entropy is one of several ways to measure biodiversity and is applied in the form of the Shannon index. A diversity index is a quantitative statistical measure of how many different types exist in a dataset, such as species in a community, accounting for ecological richness, evenness, and dominance. Specifically, Shannon entropy is the logarithm of D, the true diversity index with parameter equal to 1. The Shannon index is related to the proportional abundances of types.

Entropy of a sequence

There are a number of entropy-related concepts that mathematically quantify information content of a sequence or message:

  • the self-information of an individual message or symbol taken from a given probability distribution (message or sequence seen as an individual event),
  • the joint entropy of the symbols forming the message or sequence (seen as a set of events),
  • the entropy rate of a stochastic process (message or sequence is seen as a succession of events).

(The "rate of self-information" can also be defined for a particular sequence of messages or symbols generated by a given stochastic process: this will always be equal to the entropy rate in the case of a stationary process.) Other quantities of information are also used to compare or relate different sources of information.

It is important not to confuse the above concepts. Often it is only clear from context which one is meant. For example, when someone says that the "entropy" of the English language is about 1 bit per character, they are actually modeling the English language as a stochastic process and talking about its entropy rate. Shannon himself used the term in this way.

If very large blocks are used, the estimate of per-character entropy rate may become artificially low because the probability distribution of the sequence is not known exactly; it is only an estimate. If one considers the text of every book ever published as a sequence, with each symbol being the text of a complete book, and if there are N published books, and each book is only published once, the estimate of the probability of each book is 1/N, and the entropy (in bits) is −log2(1/N) = log2(N). As a practical code, this corresponds to assigning each book a unique identifier and using it in place of the text of the book whenever one wants to refer to the book. This is enormously useful for talking about books, but it is not so useful for characterizing the information content of an individual book, or of language in general: it is not possible to reconstruct the book from its identifier without knowing the probability distribution, that is, the complete text of all the books. The key idea is that the complexity of the probabilistic model must be considered. Kolmogorov complexity is a theoretical generalization of this idea that allows the consideration of the information content of a sequence independent of any particular probability model; it considers the shortest program for a universal computer that outputs the sequence. A code that achieves the entropy rate of a sequence for a given model, plus the codebook (i.e. the probabilistic model), is one such program, but it may not be the shortest.

The Fibonacci sequence is 1, 1, 2, 3, 5, 8, 13, .... treating the sequence as a message and each number as a symbol, there are almost as many symbols as there are characters in the message, giving an entropy of approximately log2(n). The first 128 symbols of the Fibonacci sequence has an entropy of approximately 7 bits/symbol, but the sequence can be expressed using a formula and this formula has a much lower entropy and applies to any length of the Fibonacci sequence.

Limitations of entropy in cryptography

In cryptanalysis, entropy is often roughly used as a measure of the unpredictability of a cryptographic key, though its real uncertainty is unmeasurable. For example, a 128-bit key that is uniformly and randomly generated has 128 bits of entropy. It also takes (on average) 2 127 {\displaystyle 2^{127}} guesses to break by brute force. Entropy fails to capture the number of guesses required if the possible keys are not chosen uniformly. Instead, a measure called guesswork can be used to measure the effort required for a brute force attack.

Other problems may arise from non-uniform distributions used in cryptography. For example, a 1,000,000-digit binary one-time pad using exclusive or. If the pad has 1,000,000 bits of entropy, it is perfect. If the pad has 999,999 bits of entropy, evenly distributed (each individual bit of the pad having 0.999999 bits of entropy) it may provide good security. But if the pad has 999,999 bits of entropy, where the first bit is fixed and the remaining 999,999 bits are perfectly random, the first bit of the ciphertext will not be encrypted at all.

Data as a Markov process

A common way to define entropy for text is based on the Markov model of text. For an order-0 source (each character is selected independent of the last characters), the binary entropy is:

H ( S ) = p i log p i , {\displaystyle \mathrm {H} ({\mathcal {S}})=-\sum p_{i}\log p_{i},}

where pi is the probability of i. For a first-order Markov source (one in which the probability of selecting a character is dependent only on the immediately preceding character), the entropy rate is:

H ( S ) = i p i j   p i ( j ) log p i ( j ) , {\displaystyle \mathrm {H} ({\mathcal {S}})=-\sum _{i}p_{i}\sum _{j}\ p_{i}(j)\log p_{i}(j),}

where i is a state (certain preceding characters) and p i ( j ) {\displaystyle p_{i}(j)} is the probability of j given i as the previous character.

For a second order Markov source, the entropy rate is

H ( S ) = i p i j p i ( j ) k p i , j ( k )   log   p i , j ( k ) . {\displaystyle \mathrm {H} ({\mathcal {S}})=-\sum _{i}p_{i}\sum _{j}p_{i}(j)\sum _{k}p_{i,j}(k)\ \log \ p_{i,j}(k).}

Efficiency (normalized entropy)

A source set X {\displaystyle {\mathcal {X}}} with a non-uniform distribution will have less entropy than the same set with a uniform distribution (i.e. the "optimized alphabet"). This deficiency in entropy can be expressed as a ratio called efficiency:

η ( X ) = H H m a x = i = 1 n p ( x i ) log b ( p ( x i ) ) log b ( n ) . {\displaystyle \eta (X)={\frac {H}{H_{max}}}=-\sum _{i=1}^{n}{\frac {p(x_{i})\log _{b}(p(x_{i}))}{\log _{b}(n)}}.}

Applying the basic properties of the logarithm, this quantity can also be expressed as:

η ( X ) = i = 1 n p ( x i ) log b ( p ( x i ) ) log b ( n ) = i = 1 n log b ( p ( x i ) p ( x i ) ) log b ( n ) = i = 1 n log n ( p ( x i ) p ( x i ) ) = log n ( i = 1 n p ( x i ) p ( x i ) ) . {\displaystyle \eta (X)=-\sum _{i=1}^{n}{\frac {p(x_{i})\log _{b}(p(x_{i}))}{\log _{b}(n)}}=\sum _{i=1}^{n}{\frac {\log _{b}(p(x_{i})^{-p(x_{i})})}{\log _{b}(n)}}=\sum _{i=1}^{n}\log _{n}(p(x_{i})^{-p(x_{i})})=\log _{n}(\prod _{i=1}^{n}p(x_{i})^{-p(x_{i})}).}

Efficiency has utility in quantifying the effective use of a communication channel. This formulation is also referred to as the normalized entropy, as the entropy is divided by the maximum entropy log b ( n ) {\displaystyle {\log _{b}(n)}} . Furthermore, the efficiency is indifferent to the choice of (positive) base b, as indicated by the insensitivity within the final logarithm above thereto.

Entropy for continuous random variables

Differential entropy

Main article: Differential entropy

The Shannon entropy is restricted to random variables taking discrete values. The corresponding formula for a continuous random variable with probability density function f(x) with finite or infinite support X {\displaystyle \mathbb {X} } on the real line is defined by analogy, using the above form of the entropy as an expectation:

H ( X ) = E [ log f ( X ) ] = X f ( x ) log f ( x ) d x . {\displaystyle \mathrm {H} (X)=\mathbb {E} =-\int _{\mathbb {X} }f(x)\log f(x)\,\mathrm {d} x.}

This is the differential entropy (or continuous entropy). A precursor of the continuous entropy h is the expression for the functional Η in the H-theorem of Boltzmann.

Although the analogy between both functions is suggestive, the following question must be set: is the differential entropy a valid extension of the Shannon discrete entropy? Differential entropy lacks a number of properties that the Shannon discrete entropy has – it can even be negative – and corrections have been suggested, notably limiting density of discrete points.

To answer this question, a connection must be established between the two functions:

In order to obtain a generally finite measure as the bin size goes to zero. In the discrete case, the bin size is the (implicit) width of each of the n (finite or infinite) bins whose probabilities are denoted by pn. As the continuous domain is generalized, the width must be made explicit.

To do this, start with a continuous function f discretized into bins of size Δ {\displaystyle \Delta } . By the mean-value theorem there exists a value xi in each bin such that f ( x i ) Δ = i Δ ( i + 1 ) Δ f ( x ) d x {\displaystyle f(x_{i})\Delta =\int _{i\Delta }^{(i+1)\Delta }f(x)\,dx} the integral of the function f can be approximated (in the Riemannian sense) by f ( x ) d x = lim Δ 0 i = f ( x i ) Δ , {\displaystyle \int _{-\infty }^{\infty }f(x)\,dx=\lim _{\Delta \to 0}\sum _{i=-\infty }^{\infty }f(x_{i})\Delta ,} where this limit and "bin size goes to zero" are equivalent.

We will denote H Δ := i = f ( x i ) Δ log ( f ( x i ) Δ ) {\displaystyle \mathrm {H} ^{\Delta }:=-\sum _{i=-\infty }^{\infty }f(x_{i})\Delta \log \left(f(x_{i})\Delta \right)} and expanding the logarithm, we have H Δ = i = f ( x i ) Δ log ( f ( x i ) ) i = f ( x i ) Δ log ( Δ ) . {\displaystyle \mathrm {H} ^{\Delta }=-\sum _{i=-\infty }^{\infty }f(x_{i})\Delta \log(f(x_{i}))-\sum _{i=-\infty }^{\infty }f(x_{i})\Delta \log(\Delta ).}

As Δ → 0, we have

i = f ( x i ) Δ f ( x ) d x = 1 i = f ( x i ) Δ log ( f ( x i ) ) f ( x ) log f ( x ) d x . {\displaystyle {\begin{aligned}\sum _{i=-\infty }^{\infty }f(x_{i})\Delta &\to \int _{-\infty }^{\infty }f(x)\,dx=1\\\sum _{i=-\infty }^{\infty }f(x_{i})\Delta \log(f(x_{i}))&\to \int _{-\infty }^{\infty }f(x)\log f(x)\,dx.\end{aligned}}}

Note; log(Δ) → −∞ as Δ → 0, requires a special definition of the differential or continuous entropy:

h [ f ] = lim Δ 0 ( H Δ + log Δ ) = f ( x ) log f ( x ) d x , {\displaystyle h=\lim _{\Delta \to 0}\left(\mathrm {H} ^{\Delta }+\log \Delta \right)=-\int _{-\infty }^{\infty }f(x)\log f(x)\,dx,}

which is, as said before, referred to as the differential entropy. This means that the differential entropy is not a limit of the Shannon entropy for n → ∞. Rather, it differs from the limit of the Shannon entropy by an infinite offset (see also the article on information dimension).

Limiting density of discrete points

Main article: Limiting density of discrete points

It turns out as a result that, unlike the Shannon entropy, the differential entropy is not in general a good measure of uncertainty or information. For example, the differential entropy can be negative; also it is not invariant under continuous co-ordinate transformations. This problem may be illustrated by a change of units when x is a dimensioned variable. f(x) will then have the units of 1/x. The argument of the logarithm must be dimensionless, otherwise it is improper, so that the differential entropy as given above will be improper. If Δ is some "standard" value of x (i.e. "bin size") and therefore has the same units, then a modified differential entropy may be written in proper form as:

H = f ( x ) log ( f ( x ) Δ ) d x , {\displaystyle \mathrm {H} =\int _{-\infty }^{\infty }f(x)\log(f(x)\,\Delta )\,dx,}

and the result will be the same for any choice of units for x. In fact, the limit of discrete entropy as N {\displaystyle N\rightarrow \infty } would also include a term of log ( N ) {\displaystyle \log(N)} , which would in general be infinite. This is expected: continuous variables would typically have infinite entropy when discretized. The limiting density of discrete points is really a measure of how much easier a distribution is to describe than a distribution that is uniform over its quantization scheme.

Relative entropy

Main article: Generalized relative entropy

Another useful measure of entropy that works equally well in the discrete and the continuous case is the relative entropy of a distribution. It is defined as the Kullback–Leibler divergence from the distribution to a reference measure m as follows. Assume that a probability distribution p is absolutely continuous with respect to a measure m, i.e. is of the form p(dx) = f(x)m(dx) for some non-negative m-integrable function f with m-integral 1, then the relative entropy can be defined as

D K L ( p m ) = log ( f ( x ) ) p ( d x ) = f ( x ) log ( f ( x ) ) m ( d x ) . {\displaystyle D_{\mathrm {KL} }(p\|m)=\int \log(f(x))p(dx)=\int f(x)\log(f(x))m(dx).}

In this form the relative entropy generalizes (up to change in sign) both the discrete entropy, where the measure m is the counting measure, and the differential entropy, where the measure m is the Lebesgue measure. If the measure m is itself a probability distribution, the relative entropy is non-negative, and zero if p = m as measures. It is defined for any measure space, hence coordinate independent and invariant under co-ordinate reparameterizations if one properly takes into account the transformation of the measure m. The relative entropy, and (implicitly) entropy and differential entropy, do depend on the "reference" measure m.

Use in number theory

Terence Tao used entropy to make a useful connection trying to solve the Erdős discrepancy problem.

Intuitively the idea behind the proof was if there is low information in terms of the Shannon entropy between consecutive random variables (here the random variable is defined using the Liouville function (which is a useful mathematical function for studying distribution of primes) XH = λ ( n + H ) {\displaystyle \lambda (n+H)} . And in an interval the sum over that interval could become arbitrary large. For example, a sequence of +1's (which are values of XH could take) have trivially low entropy and their sum would become big. But the key insight was showing a reduction in entropy by non negligible amounts as one expands H leading inturn to unbounded growth of a mathematical object over this random variable is equivalent to showing the unbounded growth per the Erdős discrepancy problem.

The proof is quite involved and it brought together breakthroughs not just in novel use of Shannon Entropy, but also its used the Liouville function along with averages of modulated multiplicative functions Archived 28 October 2023 at the Wayback Machine in short intervals. Proving it also broke the "parity barrier" Archived 7 August 2023 at the Wayback Machine for this specific problem.

While the use of Shannon Entropy in the proof is novel it is likely to open new research in this direction.

Use in combinatorics

Entropy has become a useful quantity in combinatorics.

Loomis–Whitney inequality

A simple example of this is an alternative proof of the Loomis–Whitney inequality: for every subset AZ, we have

| A | d 1 i = 1 d | P i ( A ) | {\displaystyle |A|^{d-1}\leq \prod _{i=1}^{d}|P_{i}(A)|}

where Pi is the orthogonal projection in the ith coordinate:

P i ( A ) = { ( x 1 , , x i 1 , x i + 1 , , x d ) : ( x 1 , , x d ) A } . {\displaystyle P_{i}(A)=\{(x_{1},\ldots ,x_{i-1},x_{i+1},\ldots ,x_{d}):(x_{1},\ldots ,x_{d})\in A\}.}

The proof follows as a simple corollary of Shearer's inequality: if X1, ..., Xd are random variables and S1, ..., Sn are subsets of {1, ..., d} such that every integer between 1 and d lies in exactly r of these subsets, then

H [ ( X 1 , , X d ) ] 1 r i = 1 n H [ ( X j ) j S i ] {\displaystyle \mathrm {H} \leq {\frac {1}{r}}\sum _{i=1}^{n}\mathrm {H} }

where ( X j ) j S i {\displaystyle (X_{j})_{j\in S_{i}}} is the Cartesian product of random variables Xj with indexes j in Si (so the dimension of this vector is equal to the size of Si).

We sketch how Loomis–Whitney follows from this: Indeed, let X be a uniformly distributed random variable with values in A and so that each point in A occurs with equal probability. Then (by the further properties of entropy mentioned above) Η(X) = log|A|, where |A| denotes the cardinality of A. Let Si = {1, 2, ..., i−1, i+1, ..., d}. The range of ( X j ) j S i {\displaystyle (X_{j})_{j\in S_{i}}} is contained in Pi(A) and hence H [ ( X j ) j S i ] log | P i ( A ) | {\displaystyle \mathrm {H} \leq \log |P_{i}(A)|} . Now use this to bound the right side of Shearer's inequality and exponentiate the opposite sides of the resulting inequality you obtain.

Approximation to binomial coefficient

For integers 0 < k < n let q = k/n. Then

2 n H ( q ) n + 1 ( n k ) 2 n H ( q ) , {\displaystyle {\frac {2^{n\mathrm {H} (q)}}{n+1}}\leq {\tbinom {n}{k}}\leq 2^{n\mathrm {H} (q)},}

where

H ( q ) = q log 2 ( q ) ( 1 q ) log 2 ( 1 q ) . {\displaystyle \mathrm {H} (q)=-q\log _{2}(q)-(1-q)\log _{2}(1-q).}
Proof (sketch)
Note that ( n k ) q q n ( 1 q ) n n q {\displaystyle {\tbinom {n}{k}}q^{qn}(1-q)^{n-nq}} is one term of the expression
i = 0 n ( n i ) q i ( 1 q ) n i = ( q + ( 1 q ) ) n = 1. {\displaystyle \sum _{i=0}^{n}{\tbinom {n}{i}}q^{i}(1-q)^{n-i}=(q+(1-q))^{n}=1.}

Rearranging gives the upper bound. For the lower bound one first shows, using some algebra, that it is the largest term in the summation. But then,

( n k ) q q n ( 1 q ) n n q 1 n + 1 {\displaystyle {\binom {n}{k}}q^{qn}(1-q)^{n-nq}\geq {\frac {1}{n+1}}}

since there are n + 1 terms in the summation. Rearranging gives the lower bound.

A nice interpretation of this is that the number of binary strings of length n with exactly k many 1's is approximately 2 n H ( k / n ) {\displaystyle 2^{n\mathrm {H} (k/n)}} .

Use in machine learning

Machine learning techniques arise largely from statistics and also information theory. In general, entropy is a measure of uncertainty and the objective of machine learning is to minimize uncertainty.

Decision tree learning algorithms use relative entropy to determine the decision rules that govern the data at each node. The information gain in decision trees I G ( Y , X ) {\displaystyle IG(Y,X)} , which is equal to the difference between the entropy of Y {\displaystyle Y} and the conditional entropy of Y {\displaystyle Y} given X {\displaystyle X} , quantifies the expected information, or the reduction in entropy, from additionally knowing the value of an attribute X {\displaystyle X} . The information gain is used to identify which attributes of the dataset provide the most information and should be used to split the nodes of the tree optimally.

Bayesian inference models often apply the principle of maximum entropy to obtain prior probability distributions. The idea is that the distribution that best represents the current state of knowledge of a system is the one with the largest entropy, and is therefore suitable to be the prior.

Classification in machine learning performed by logistic regression or artificial neural networks often employs a standard loss function, called cross-entropy loss, that minimizes the average cross entropy between ground truth and predicted distributions. In general, cross entropy is a measure of the differences between two datasets similar to the KL divergence (also known as relative entropy).

See also

Notes

  1. This definition allows events with probability 0, resulting in the undefined log ( 0 ) {\displaystyle \log(0)} . We do see lim x 0 x log ( x ) = 0 {\displaystyle \lim \limits _{x\rightarrow 0}x\log(x)=0} and it can be assumed that 0 log ( 0 ) {\displaystyle 0\log(0)} equals 0 in this context. Alternatively one can define p : X ( 0 , 1 ] {\displaystyle p\colon {\mathcal {X}}\to (0,1]} , not allowing events with probability equal to exactly 0.

References

  1. Pathria, R. K.; Beale, Paul (2011). Statistical Mechanics (Third ed.). Academic Press. p. 51. ISBN 978-0123821881.
  2. ^ Shannon, Claude E. (July 1948). "A Mathematical Theory of Communication". Bell System Technical Journal. 27 (3): 379–423. doi:10.1002/j.1538-7305.1948.tb01338.x. hdl:10338.dmlcz/101429. (PDF, archived from here Archived 20 June 2014 at the Wayback Machine)
  3. ^ Shannon, Claude E. (October 1948). "A Mathematical Theory of Communication". Bell System Technical Journal. 27 (4): 623–656. doi:10.1002/j.1538-7305.1948.tb00917.x. hdl:11858/00-001M-0000-002C-4317-B. (PDF, archived from here Archived 10 May 2013 at the Wayback Machine)
  4. "Entropy (for data science) Clearly Explained!!!". 24 August 2021. Archived from the original on 5 October 2021. Retrieved 5 October 2021 – via YouTube.
  5. MacKay, David J.C. (2003). Information Theory, Inference, and Learning Algorithms. Cambridge University Press. ISBN 0-521-64298-1. Archived from the original on 17 February 2016. Retrieved 9 June 2014.
  6. Schneier, B: Applied Cryptography, Second edition, John Wiley and Sons.
  7. Borda, Monica (2011). Fundamentals in Information Theory and Coding. Springer. ISBN 978-3-642-20346-6.
  8. Han, Te Sun; Kobayashi, Kingo (2002). Mathematics of Information and Coding. American Mathematical Society. ISBN 978-0-8218-4256-0.
  9. Schneider, T.D, Information theory primer with an appendix on logarithms, National Cancer Institute, 14 April 2007.
  10. ^ Thomas M. Cover; Joy A. Thomas (1991). Elements of Information Theory. Hoboken, New Jersey: Wiley. ISBN 978-0-471-24195-9.
  11. Entropy at the nLab
  12. Carter, Tom (March 2014). An introduction to information theory and entropy (PDF). Santa Fe. Archived (PDF) from the original on 4 June 2016. Retrieved 4 August 2017.{{cite book}}: CS1 maint: location missing publisher (link)
  13. Chakrabarti, C. G., and Indranil Chakrabarty. "Shannon entropy: axiomatic characterization and application." International Journal of Mathematics and Mathematical Sciences 2005. 17 (2005): 2847-2854 url Archived 5 October 2021 at the Wayback Machine
  14. Ellerman, David (October 2017). "Logical Information Theory: New Logical Foundations for Information Theory" (PDF). Logic Journal of the IGPL. 25 (5): 806–835. doi:10.1093/jigpal/jzx022. Archived (PDF) from the original on 25 December 2022. Retrieved 2 November 2022.
  15. ^ Aczél, J.; Forte, B.; Ng, C. T. (1974). "Why the Shannon and Hartley entropies are 'natural'". Advances in Applied Probability. 6 (1): 131–146. doi:10.2307/1426210. JSTOR 1426210. S2CID 204177762.
  16. Compare: Boltzmann, Ludwig (1896, 1898). Vorlesungen über Gastheorie : 2 Volumes – Leipzig 1895/98 UB: O 5262-6. English version: Lectures on gas theory. Translated by Stephen G. Brush (1964) Berkeley: University of California Press; (1995) New York: Dover ISBN 0-486-68455-5
  17. Życzkowski, Karol (2006). Geometry of Quantum States: An Introduction to Quantum Entanglement. Cambridge University Press. p. 301.
  18. Sharp, Kim; Matschinsky, Franz (2015). "Translation of Ludwig Boltzmann's Paper "On the Relationship between the Second Fundamental Theorem of the Mechanical Theory of Heat and Probability Calculations Regarding the Conditions for Thermal Equilibrium"". Entropy. 17: 1971–2009. doi:10.3390/e17041971.
  19. Jaynes, E. T. (15 May 1957). "Information Theory and Statistical Mechanics". Physical Review. 106 (4): 620–630. Bibcode:1957PhRv..106..620J. doi:10.1103/PhysRev.106.620. S2CID 17870175.
  20. Landauer, R. (July 1961). "Irreversibility and Heat Generation in the Computing Process". IBM Journal of Research and Development. 5 (3): 183–191. doi:10.1147/rd.53.0183. ISSN 0018-8646. Archived from the original on 15 December 2021. Retrieved 15 December 2021.
  21. Mark Nelson (24 August 2006). "The Hutter Prize". Archived from the original on 1 March 2018. Retrieved 27 November 2008.
  22. ^ "The World's Technological Capacity to Store, Communicate, and Compute Information" Archived 27 July 2013 at the Wayback Machine, Martin Hilbert and Priscila López (2011), Science, 332(6025); free access to the article through here: martinhilbert.net/WorldInfoCapacity.html
  23. Spellerberg, Ian F.; Fedor, Peter J. (2003). "A tribute to Claude Shannon (1916–2001) and a plea for more rigorous use of species richness, species diversity and the 'Shannon–Wiener' Index". Global Ecology and Biogeography. 12 (3): 177–179. Bibcode:2003GloEB..12..177S. doi:10.1046/j.1466-822X.2003.00015.x. ISSN 1466-8238. S2CID 85935463.
  24. Massey, James (1994). "Guessing and Entropy" (PDF). Proc. IEEE International Symposium on Information Theory. Archived (PDF) from the original on 1 January 2014. Retrieved 31 December 2013.
  25. Malone, David; Sullivan, Wayne (2005). "Guesswork is not a Substitute for Entropy" (PDF). Proceedings of the Information Technology & Telecommunications Conference. Archived (PDF) from the original on 15 April 2016. Retrieved 31 December 2013.
  26. Pliam, John (1999). "Selected Areas in Cryptography". International Workshop on Selected Areas in Cryptography. Lecture Notes in Computer Science. Vol. 1758. pp. 62–77. doi:10.1007/3-540-46513-8_5. ISBN 978-3-540-67185-5.
  27. Indices of Qualitative Variation. AR Wilcox - 1967 https://www.osti.gov/servlets/purl/4167340
  28. Klarreich, Erica (1 October 2015). "A Magical Answer to an 80-Year-Old Puzzle". Quanta Magazine. Retrieved 18 August 2014.
  29. Tao, Terence (28 February 2016). "The Erdős discrepancy problem". Discrete Analysis. arXiv:1509.05363v6. doi:10.19086/da.609. S2CID 59361755. Archived from the original on 25 September 2023. Retrieved 20 September 2023.
  30. Aoki, New Approaches to Macroeconomic Modeling.
  31. Probability and Computing, M. Mitzenmacher and E. Upfal, Cambridge University Press
  32. Batra, Mridula; Agrawal, Rashmi (2018). "Comparative Analysis of Decision Tree Algorithms". In Panigrahi, Bijaya Ketan; Hoda, M. N.; Sharma, Vinod; Goel, Shivendra (eds.). Nature Inspired Computing. Advances in Intelligent Systems and Computing. Vol. 652. Singapore: Springer. pp. 31–36. doi:10.1007/978-981-10-6747-1_4. ISBN 978-981-10-6747-1. Archived from the original on 19 December 2022. Retrieved 16 December 2021.
  33. Jaynes, Edwin T. (September 1968). "Prior Probabilities". IEEE Transactions on Systems Science and Cybernetics. 4 (3): 227–241. doi:10.1109/TSSC.1968.300117. ISSN 2168-2887. Archived from the original on 16 December 2021. Retrieved 16 December 2021.
  34. Rubinstein, Reuven Y.; Kroese, Dirk P. (9 March 2013). The Cross-Entropy Method: A Unified Approach to Combinatorial Optimization, Monte-Carlo Simulation and Machine Learning. Springer Science & Business Media. ISBN 978-1-4757-4321-0.

This article incorporates material from Shannon's entropy on PlanetMath, which is licensed under the Creative Commons Attribution/Share-Alike License.

Further reading

Textbooks on information theory

External links

Library resources about
Entropy (information theory)
Data compression methods
Lossless
Entropy type
Dictionary type
Other types
Hybrid
Lossy
Transform type
Predictive type
Audio
Concepts
Codec parts
Image
Concepts
Methods
Video
Concepts
Codec parts
Theory
Community
People
Categories: