中文是熵排截, /shāng/。下面是個簡單科普:
是一種測量在動力學方面不能做功的能量總數(shù)挠蛉,也就是當總體的熵增加祭示,其做功能力也下降,熵的量度正是能量退化的指標谴古。熵亦被用于計算一個系統(tǒng)中的失序現(xiàn)象质涛,也就是計算該系統(tǒng)混亂的程度。熵是一個描述系統(tǒng)狀態(tài)的函數(shù)掰担,但是經(jīng)常用熵的參考值和變化量進行分析比較汇陆,它在控制論、概率論带饱、數(shù)論毡代、天體物理、生命科學等領(lǐng)域都有重要應(yīng)用勺疼,在不同的學科中也有引申出的更為具體的定義教寂,是各領(lǐng)域十分重要的參量。
在信息論中恢口,熵是接收的每條消息中包含的信息的平均量孝宗,又被稱為信息熵、信源熵耕肩、平均自信息量因妇。這里,“消息”代表來自分布或數(shù)據(jù)流中的事件猿诸、樣本或特征婚被。
這句話我暫時沒有理解:
(熵最好理解為不確定性的量度而不是確定性的量度,因為越隨機的信源的熵越大梳虽。)
來自信源的另一個特征是樣本的概率分布址芯。這里的想法是,比較不可能發(fā)生的事情窜觉,當它發(fā)生了谷炸,會提供更多的信息。
由于一些其他的原因禀挫,把信息(熵)定義為 概率分布的對數(shù)的相反數(shù) 是有道理的旬陡。事件的概率分布和每個事件的信息量構(gòu)成了一個隨機變量,這個隨機變量的均值(即期望)就是這個分布產(chǎn)生的信息量的平均值(即熵)语婴。熵的單位通常為比特描孟,但也用Sh驶睦、nat、Hart計量匿醒,取決于定義用到對數(shù)的底场航。
采用概率分布的對數(shù)作為信息的量度的原因是其可加性。
例如廉羔,投擲一次硬幣提供了1 Sh的信息溉痢,而擲m次就為m位。更一般地蜜另,你需要用log2(n)位來表示一個可以取n個值的變量适室。
在1948年,克勞德·艾爾伍德·香農(nóng)將熱力學的熵举瑰,引入到信息論,因此它又被稱為香農(nóng)熵蔬螟。
Model for Information
觀察發(fā)生概率為p 的事件此迅,得到的信息為i(p)
- i(p) ≥ 0 : information never decrease,得到的信息永遠增加
- i(1) = 0 : observing a certain event adds no information 必然發(fā)生的時間旧巾,是得不到信息的
- i(p1p2) = i(p1)+i(p2): information from observing independent events are additive 信息可以相加
信息論之父克勞德·香農(nóng)耸序,總結(jié)出了信息熵的三條性質(zhì):
- 單調(diào)性,即發(fā)生概率越高的事件鲁猩,其所攜帶的信息熵越低坎怪。極端案例就是“太陽從東方升起”,因為為確定事件廓握,所以不攜帶任何信息量搅窿。從信息論的角度,認為這句話沒有消除任何不確定性隙券。
- 非負性男应,即信息熵不能為負。這個很好理解娱仔,因為負的信息沐飘,即你得知了某個信息后,卻增加了不確定性是不合邏輯的牲迫。
- 累加性耐朴,即多隨機事件同時發(fā)生存在的總不確定性的量度是可以表示為各事件不確定性的量度的和。
能滿足上面的模型盹憎,最簡單就是 i(p) = ?log(p)
Shannon's Information Entropy
上面是離散的和連續(xù)的 變量 x浪的 Entropy 函數(shù)
直覺上筛峭,信息量等于傳輸該信息所用的代價,這個也是通信中考慮最多的問題脚乡。比如說:賭馬比賽里蜒滩,有4匹馬{A, B, C, D} 滨达,獲勝概率分別為 1/2, 1/4俯艰,1/8捡遍, 1/8
如果 A ,那么需要問1次(問題1:是不是A竹握?)画株,概率為1/2煞赢;
如果 B 牢屋,那么需要問2次(問題1:是不是A?問題2:是不是B聘殖?)芹关,概率為 1/4 续挟;
如果 C ,那么需要問3次(問題1侥衬,問題2诗祸,問題3),概率為 1/8 ;
如果 D 轴总,那么同樣需要問3次(問題1直颅,問題2,問題3)怀樟,概率為 1/8
為了確定 贏的馬功偿,在這種問法下, 取值的二元問題數(shù)量為:
那么我們回到信息熵的定義往堡,會發(fā)現(xiàn)通過之前的信息熵公式械荷,神奇地得到了:
這樣就很好理解信息熵的概念,
這部分去看 知乎 - 信息熵是什么投蝉?
- 這句話我也沒有太理解养葵,信息熵 Information entropy 是 分布的 disorder
- why this is not a good model for knowledge? For Shannon's Information Entropy
下面是拋硬幣的entropy情況
%pylab inline
import warnings
warnings.filterwarnings('ignore')
p = np.array([.5, .25, .01])
print(-p*np.log2(p) - (1-p)*np.log2(1-p))
>>>
Populating the interactive namespace from numpy and matplotlib
[ 1. 0.81127812 0.08079314]
Underdetermined problem
An optimization problem with more variables than constraints:
關(guān)于變量比 約束多的 優(yōu)化問題:
- has infinite number of solutions 有無數(shù)的解決方案
- requires an objective function for a unique solution 需要一個獨特解決方案的目標函數(shù)
- common problem in quant finance
- finding implied distribution from few liquid market prices 從流動性差的市場價格中找到隱含分布
- curve building
In (early) literature, various ad hoc objective functions are used: 目標函數(shù)
- e.g.: sum of squares of first and second order derivatives 例一階和二階導(dǎo)數(shù)的平方和
Ignorance is strength
Disorder (or the lack of information) in a distribution is highly desirable:
分布中的無序,信息缺失是非常需要的
- more uncertainty in outcome, leaves open more possibilities 結(jié)果中更多的不確定性瘩缆,留下更多的可能性
- free from the contamination of irrelevant and artificial restrictions 不受無關(guān)和人為限制的干擾
- the distribution is smooth and well behaved 分布光滑且表現(xiàn)良好
- more difficult to arbitrage against 更難以套利
Max entropy is the ideal objective for finding implied distributions:
最大熵是尋找隱含分布的理想目標
- much better than ad hoc smoothness constraints 比特設(shè)光滑度限制好
- invokes the higher principles of the information theory 引用信息論的更高原則
Maximum Entropy Method
離散分布的信息熵最大值
- exp(p), log(p) 都是列向量
- 對p 求導(dǎo) d/dp (p^T * log(p)) = log(p^T) + 1^T
- 我們只考慮線性約束关拒,在實踐中易于處理和充分
- 連續(xù)分布可以用積分來表示。
在后面的操作中庸娱,其實都是:為了把原帶約束的極值問題轉(zhuǎn)換為無約束的極值問題着绊,一般引入拉格朗日乘子,建立拉格朗日函數(shù)熟尉,然后對拉格朗日函數(shù)求導(dǎo)归露,令求導(dǎo)結(jié)果等于0,得到極值斤儿。
Maximum Entropy Method 問題:
- 1^T p = 1 的1 是什么意思
- Ap = b b是什么意思
- 這個我也不完全懂:對p 求導(dǎo) d/dp (p^T * log(p)) = log(p^T) + 1^T
Uniform distribution
均勻分布在所有分布中剧包,具有最大熵
使得log(p)在 = -(1+ λ) 1 時有最大值
Uniform distribution問題:
- 1 究竟是什么恐锦?
- 應(yīng)用拉格朗日乘數(shù),后面λ部分應(yīng)該是約束條件疆液。究竟是個什么約束條件一铅?
Normal distribution
Normal distribution has the maximum entropy with given mean and variance
正態(tài)分布給定均值和方差時有最大熵
- This explains the ubiquity of the normal distribution 解釋了正態(tài)分布的普遍性
- Knowing only mean and variance, we have to assume the distribution is normal 只知道均值和方差,我們必須假設(shè)分布是正常的
有三個約束條件
Normal distribution問題:
- 三個約束條件都是怎么得出來的堕油?
Exponential distribution
Exponential distribution has the maximum entropy for a positive random variable with a given expectation 指數(shù)分布在給定期望的正隨機變量時潘飘,有最大熵
-
Without addtional information, we have to assume all survival times are exponetially distributed. 沒有附加信息,我們必須假設(shè)所有survival times 都是指數(shù)分布的掉缺。
比較一下正太分布卜录,約束條件都有:
- p(x)dx - 1
- xp(x)dx - μ
寫個例子
%pylab inline
import me
from scipy.optimize import minimize
import pandas as pd
lecture = 10
matplotlib.rcParams.update({'font.size': 14})
x = np.arange(0, 10, .05)
a = np.array([x])
u = np.array([1.])
e = np.array([0])
q = np.ones(np.size(x))
dual = me.MaxEntDual(q, a, u, e)
res = minimize(dual.dual, np.zeros(len(u)), jac=dual.grad, method="BFGS")
figure(figsize=[12, 8])
subplot(2, 2, 1)
plot(x, dual.dist(res.x));
title('$x>0, \mathbb{E}[x]=1$');
subplot(2, 2, 3)
x = np.arange(-13., 13., .01)
a = np.array([x, x*x])
u = np.array([0., 1.])
e = np.array([0., 0.])
q = np.ones(np.size(x))/len(q)
dual = me.MaxEntDual(q, a, u, e)
res = minimize(dual.dual, np.zeros(len(u)), jac=dual.grad, method="BFGS")
semilogy(x, dual.dist(res.x))
xlim(-8, 8)
ylim(1e-16, 1e-2)
title('$\mathbb{E}[x] = 0, \mathbb{E}[x^2] = 1$');
subplot(2, 2, 4)
a = np.vstack([a, x*x*x*x])
u = np.append(u, 20)
e = np.append(e, 0)
dual = me.MaxEntDual(q, a, u, e)
res = minimize(dual.dual, np.zeros(len(u)), jac=dual.grad, method="BFGS")
semilogy(x, dual.dist(res.x))
xlim(-8, 8)
title('$\mathbb{E}[x] = 0, \mathbb{E}[x^2] = 1, \mathbb{E}[x^4] = 20$');
subplot(2, 2, 2)
a = np.vstack([a, x*x*x])
u = np.append(u, -4)
e = np.append(e, 0)
dual = me.MaxEntDual(q, a, u, e)
res = minimize(dual.dual, np.zeros(len(u)), jac=dual.grad, method="BFGS")
plot(x, dual.dist(res.x))
xlim(-8, 4)
title('$\mathbb{E}[x] = 0, \mathbb{E}[x^2] = 1, \mathbb{E}[x^3] = -4, \mathbb{E}[x^4] = 20$');
這一塊老師用了他自己的 import me
同時我也不太理解他的 MaxEntDual 是什么?先跳過眶明,之后要回來再找找艰毒。
Shannon's Information Entropy問題:
- 這句話我也沒有太理解,信息熵 Information entropy 是 分布的 disorder
- why this is not a good model for knowledge? For Shannon's Information Entropy
Maximum Entropy Method 問題:
- 1^T p = 1 的1 是什么意思
- Ap = b b是什么意思
- 這個我也不完全懂:對p 求導(dǎo) d/dp (p^T * log(p)) = log(p^T) + 1^T
Uniform distribution問題:
- 1 究竟是什么赘来?
- 應(yīng)用拉格朗日乘數(shù)现喳,后面λ部分應(yīng)該是約束條件。究竟是個什么約束條件犬辰?
Normal distribution問題:
- 三個約束條件都是怎么得出來的?