一文看懂信息熵的本质——谈谈自己对信息熵的理解
一、序言
初次看到信息熵的公式有很多不理解的地方,只知道信息熵如何进行计算,却不懂得公式背后的原理,我通过查阅了一些资料,加深了对信息熵的理解,现在将这些理解分享给大家。如有疑问欢迎评论,若对你有帮助,麻烦点个赞。未经允许、请勿转载。(本文适合只知道信息熵的公式,但是不明白其中原理的人进行阅读)
二、什么是信息熵
正如我们想要衡量某个物体的质量引入了克这个单位、我们想衡量时间,我们设计一秒钟这么长。香农老人家想要量化一条消息中带有的“信息量”的大小,提出了信息熵。
那么,首先明确一个问题,什么样的消息算作“信息量大”呢?什么样的消息又算作“信息量小呢”?举个例子昨天小明和我说:“今天罗志祥又和周扬青秀恩爱了!”,我就觉得这有啥的,他们天天秀恩爱。也就是说小明的这条消息并不能给我带来很大的信息量。
BUT今天小明和我说:”周扬青怒锤罗志祥!!!罗志祥人设崩塌!!!“,我就会很惊讶,因为这条消息给我的信息量很大。(类似的信息量很大的消息还有:小明告诉我今天太阳会从西边升起)
我们用信息熵来描述一个事件混乱程度的大小(一个事件我们一定知道结果,那么这个事件的混乱程度就是0;一个时间充满随机性,我们猜不到或者很难猜到结果,那么他的混乱度就很大)
引用下面一个在箱子里面摸球的例子,我们来更具体的了解信息熵。
(此例引自:Youtube的一个视频)
图左侧中有一个装有四个球的封闭箱子(这个箱子里面有三个红球、一个蓝球),现在我们从箱子中随机取出一个球,记录它的颜色后再放回箱子中,重复四次操作。如果你依次取出的序列为右上角所示(第一次取到红色、第二次取到红色、第三次取到红色、第四次取到蓝色),则你可以获得奖金;否则你就输了。大家用初中数学来算一算,我赢得奖金的概率是
P
(
x
)
=
3
4
∗
3
4
∗
3
4
∗
1
4
=
27
256
P(x)=\frac{3}{4}*\frac{3}{4}*\frac{3}{4}*\frac{1}{4}=\frac{27}{256}
</span><span class="katex-html"><span class="base"><span class="strut" style="height: 0.68em; vertical-align: 0em;"></span><span class="mord mathdefault" style="margin-right: 0.13em;">P</span><span class="mord cjk_fallback">(</span><span class="mord mathdefault">x</span><span class="mord cjk_fallback">)</span><span class="mspace" style="margin-right: 0.27em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.27em;"></span></span><span class="base"><span class="strut" style="height: 2em; vertical-align: -0.68em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.32em;"><span style="top: -2.31em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">4</span></span></span><span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span style="top: -3.67em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">3</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.68em;"></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">∗</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 2em; vertical-align: -0.68em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.32em;"><span style="top: -2.31em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">4</span></span></span><span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span style="top: -3.67em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">3</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.68em;"></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">∗</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 2em; vertical-align: -0.68em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.32em;"><span style="top: -2.31em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">4</span></span></span><span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span style="top: -3.67em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">3</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.68em;"></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">∗</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 2em; vertical-align: -0.68em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.32em;"><span style="top: -2.31em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">4</span></span></span><span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span style="top: -3.67em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.68em;"></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.27em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.27em;"></span></span><span class="base"><span class="strut" style="height: 2em; vertical-align: -0.68em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.32em;"><span style="top: -2.31em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">2</span><span class="mord">5</span><span class="mord">6</span></span></span><span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span style="top: -3.67em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">2</span><span class="mord">7</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.68em;"></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></span><br> 现在明确了这个游戏的规则,那么我们分析一下如下几个箱子与赢得奖金的情况,分别计算一下获胜概率<br> <img alt="在这里插入图片描述" src="https://img-blog.csdnimg.cn/20200423165753935.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM1NjI0MDMw,size_16,color_FFFFFF,t_70"><br> <img alt="在这里插入图片描述" src="https://img-blog.csdnimg.cn/20200423165836890.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM1NjI0MDMw,size_16,color_FFFFFF,t_70"><br> <img alt="在这里插入图片描述" src="https://img-blog.csdnimg.cn/20200423165853642.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM1NjI0MDMw,size_16,color_FFFFFF,t_70"><br> (每个图的左边是这个箱子的红球与蓝球初始条件,右侧是获胜所要求的序列,大家自己算算这个概率和图上写的一样吗?)<br> <img alt="在这里插入图片描述" src="https://img-blog.csdnimg.cn/20200423170009974.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM1NjI0MDMw,size_16,color_FFFFFF,t_70"><br> 我们来分析一下这三种状态的游戏,第一次由于箱子内全是红球、该箱子的随机性很弱,也就是说还没摸我就知道结果了。这种状态带来的信息量很小;第三个箱子随机性很强,也就是说,对于结果我们充满未知。这个状态的信息量很大。我们算出的这个概率越接近1时候,这个信息熵应该越接近0;算出的这个概率越小的时候,信息熵反而应该越大。我们需要找到这么一个公式来满足这一点。(暂停思考一下,有哪些公式可以满足)<br> <strong>该可以很轻松的想到,用刚才P(winning)的概率取倒数可以吗?</strong> 答案是,只考虑刚才的问题,是可以的。但取倒数这个方式还是存在一些问题,比如第三个箱子取0.0625的倒数,算出来的这个信息量为16,如果这个P(winning)概率算出结果很小时,取倒数后就会变得非常大,所以我们认为这个乘法的规则并不是很好(换言之,我们希望曲线平滑一些)。香农发现log函数可以很好的解决这个问题。 因为log(a*b) = log(a)+log(b);而恰巧像抽箱子的独立事件P(AB) = P(A)*P(B)。【原因不止于此,后面我们还会再详细讨论】。<br> 所以香农取了一个-log(x)这么一个函数来表示某一状态的信息量大小,因为x是概率事件取[0,1],所以log(x)是一个递增的恒负的值,取一个负号,-log(x)是一个恒正、递减的函数,正好符合我们的预期。<br> <img alt="在这里插入图片描述" src="https://img-blog.csdnimg.cn/2020042410083693.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM1NjI0MDMw,size_16,color_FFFFFF,t_70"></p>
表的第四列就是我们用log计算出的结果。而我们刚刚是依次计算的每一个球的结果,为了表示系统的平均信息量。我们除4得到最终的信息熵。
我们来将这个模型一般化,m个红球n个蓝球,信息熵表示如上图所示。
我们可以再将模型一般化一些,如果这个箱子里有多种不同颜色的球,我们就公式变成了如下的样子:
H
(
x
)
=
−
∑
i
=
1
n
P
(
x
i
)
∗
l
o
g
(
P
(
x
i
)
)
H_{(x)}= -\sum_{i=1}^{n}P_{(x_i)}*log(P(x_i))\,
</span><span class="katex-html"><span class="base"><span class="strut" style="height: 1.03em; vertical-align: -0.35em;"></span><span class="mord"><span class="mord mathdefault" style="margin-right: 0.08em;">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.34em;"><span style="top: -2.51em; margin-right: 0.05em; margin-left: -0.08em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mopen mtight">(</span><span class="mord mathdefault mtight">x</span><span class="mclose mtight">)</span></span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.35em;"></span></span></span></span></span><span class="mspace" style="margin-right: 0.27em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.27em;"></span></span><span class="base"><span class="strut" style="height: 2.92em; vertical-align: -1.27em;"></span><span class="mord">−</span><span class="mspace" style="margin-right: 0.16em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.65em;"><span style="top: -1.87em; margin-left: 0em;"><span class="pstrut" style="height: 3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathdefault mtight">i</span><span class="mrel mtight">=</span><span class="mord mtight">1</span></span></span></span><span style="top: -3.05em;"><span class="pstrut" style="height: 3.05em;"></span><span class="mop op-symbol large-op">∑</span></span><span style="top: -4.3em; margin-left: 0em;"><span class="pstrut" style="height: 3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathdefault mtight">n</span></span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 1.27em;"></span></span></span></span><span class="mspace" style="margin-right: 0.16em;"></span><span class="mord"><span class="mord mathdefault" style="margin-right: 0.13em;">P</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.34em;"><span style="top: -2.51em; margin-right: 0.05em; margin-left: -0.13em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mopen mtight">(</span><span class="mord mtight"><span class="mord mathdefault mtight">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.32em;"><span style="top: -2.35em; margin-right: 0.07em; margin-left: 0em;"><span class="pstrut" style="height: 2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mathdefault mtight">i</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.14em;"></span></span></span></span></span><span class="mclose mtight">)</span></span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.35em;"></span></span></span></span></span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">∗</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathdefault" style="margin-right: 0.01em;">l</span><span class="mord mathdefault">o</span><span class="mord mathdefault" style="margin-right: 0.03em;">g</span><span class="mopen">(</span><span class="mord mathdefault" style="margin-right: 0.13em;">P</span><span class="mopen">(</span><span class="mord"><span class="mord mathdefault">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.31em;"><span style="top: -2.55em; margin-right: 0.05em; margin-left: 0em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathdefault mtight">i</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"></span></span></span></span></span><span class="mclose">)</span><span class="mclose">)</span><span class="mspace" style="margin-right: 0.16em;"></span></span></span></span></span></span><br> 这就是信息熵。<strong>也就是说,我们规定拿出一枚硬币,随意投出后,他可能是正面也可能是反面,它的信息熵是单位1(用刚才的方法来算算是不是1)。就像我们在这节开始所提到的,我们知道一个物体是几千克。是因为我们有一个1kg的砝码作为参考。我们能感受到时间流逝了多少秒,是因为我们规定了秒的单位。</strong></p>
三、为什么是log
这章我们会再用一个例子来讲解,为什么是信息熵为什么要用log?还是以一个游戏为例。
在上述的8个字母中,任取一个字母(我们不知道取的是什么,但我们知道初始的8个字母是什么),现在让你来猜这个字母是什么。
利用我们刚刚学过的信息熵,我们可以知道第一个序列的信息熵很低、第三个最高。我们可以计算出如下结果
(这个信息熵大家自己算一下,和上面计算的方式完全一样)
重点来了: 下面我们用一种提问的方式,来解决这个问题。你可以像系统提问(比如:这个字符是A吗?),系统会给你回答,你根据回答继续进行提问,直到猜到结果为止。以第二个序列为例;系统选了D,让你来猜。你会这样提问:
Q1:这个字符是A吗? Answer:不是
你就知道,这个答案只能是B,C,D中的一个,你就会继续提问:
Q2:这个字符是B吗? Answer:不是
你就会继续问:
Q3:这个字符是C吗?Answer:不是
好了,你不会再继续问下去了,因为这个答案一定是D。
也就是说通过这种方式,如果答案是A,你会猜1次,答案是B你会猜两次,答案是C或者D,你会猜三次。平均猜测次数为
E
(
x
)
=
1
4
∗
1
+
1
4
∗
2
+
1
4
∗
3
+
1
4
∗
3
=
2.25
次
E(x)=\frac{1}{4}*1+\frac{1}{4}*2+\frac{1}{4}*3+\frac{1}{4}*3=2.25次
</span><span class="katex-html"><span class="base"><span class="strut" style="height: 0.68em; vertical-align: 0em;"></span><span class="mord mathdefault" style="margin-right: 0.05em;">E</span><span class="mord cjk_fallback">(</span><span class="mord mathdefault">x</span><span class="mord cjk_fallback">)</span><span class="mspace" style="margin-right: 0.27em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.27em;"></span></span><span class="base"><span class="strut" style="height: 2em; vertical-align: -0.68em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.32em;"><span style="top: -2.31em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">4</span></span></span><span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span style="top: -3.67em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.68em;"></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">∗</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 0.72em; vertical-align: -0.08em;"></span><span class="mord">1</span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 2em; vertical-align: -0.68em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.32em;"><span style="top: -2.31em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">4</span></span></span><span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span style="top: -3.67em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.68em;"></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">∗</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 0.72em; vertical-align: -0.08em;"></span><span class="mord">2</span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 2em; vertical-align: -0.68em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.32em;"><span style="top: -2.31em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">4</span></span></span><span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span style="top: -3.67em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.68em;"></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">∗</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 0.72em; vertical-align: -0.08em;"></span><span class="mord">3</span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 2em; vertical-align: -0.68em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.32em;"><span style="top: -2.31em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">4</span></span></span><span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span style="top: -3.67em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.68em;"></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">∗</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 0.64em; vertical-align: 0em;"></span><span class="mord">3</span><span class="mspace" style="margin-right: 0.27em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.27em;"></span></span><span class="base"><span class="strut" style="height: 0.64em; vertical-align: 0em;"></span><span class="mord">2</span><span class="mord">.</span><span class="mord">2</span><span class="mord">5</span><span class="mord cjk_fallback">次</span></span></span></span></span></span><br> 显然,你可以选择一种更精妙的提问方式,来缩减平均猜测的次数<br> 你可以这样进行提问:<br> Q1:这个字符是A或B吗? Answer:不是<br> Q2:那么这个字符是C吗? Answer:不是<br> 好了,那么我知道这个字符是D了。也就是通过这种方式,我们不管是哪一个字符,我们只需要问两次就可以解决问题,我们用一种更直观的树来表示,如下图所示<br> <img alt="在这里插入图片描述" src="https://img-blog.csdnimg.cn/20200424101310790.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM1NjI0MDMw,size_16,color_FFFFFF,t_70"><br> <strong>恰巧,这种提问二选一的过程,恰巧是个抛硬币的过程。由于我们类似的等价于抛了两次硬币,我们可以知道,这个过程的信息熵是2。我们再用信息熵的公式试一试</strong><br> <span class="katex--display"><span class="katex-display"><span class="katex"><span class="katex-mathml">
H
(
x
)
=
1
4
∗
l
o
g
(
4
)
+
1
4
∗
l
o
g
(
4
)
+
1
4
∗
l
o
g
(
4
)
+
1
4
∗
l
o
g
(
4
)
=
2
H(x)=\frac{1}{4}*log(4)+\frac{1}{4}*log(4)+\frac{1}{4}*log(4)+\frac{1}{4}*log(4)=2
</span><span class="katex-html"><span class="base"><span class="strut" style="height: 0.68em; vertical-align: 0em;"></span><span class="mord mathdefault" style="margin-right: 0.08em;">H</span><span class="mord cjk_fallback">(</span><span class="mord mathdefault">x</span><span class="mord cjk_fallback">)</span><span class="mspace" style="margin-right: 0.27em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.27em;"></span></span><span class="base"><span class="strut" style="height: 2em; vertical-align: -0.68em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.32em;"><span style="top: -2.31em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">4</span></span></span><span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span style="top: -3.67em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.68em;"></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">∗</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathdefault" style="margin-right: 0.01em;">l</span><span class="mord mathdefault">o</span><span class="mord mathdefault" style="margin-right: 0.03em;">g</span><span class="mopen">(</span><span class="mord">4</span><span class="mclose">)</span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 2em; vertical-align: -0.68em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.32em;"><span style="top: -2.31em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">4</span></span></span><span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span style="top: -3.67em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.68em;"></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">∗</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathdefault" style="margin-right: 0.01em;">l</span><span class="mord mathdefault">o</span><span class="mord mathdefault" style="margin-right: 0.03em;">g</span><span class="mopen">(</span><span class="mord">4</span><span class="mclose">)</span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 2em; vertical-align: -0.68em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.32em;"><span style="top: -2.31em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">4</span></span></span><span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span style="top: -3.67em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.68em;"></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">∗</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathdefault" style="margin-right: 0.01em;">l</span><span class="mord mathdefault">o</span><span class="mord mathdefault" style="margin-right: 0.03em;">g</span><span class="mopen">(</span><span class="mord">4</span><span class="mclose">)</span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 2em; vertical-align: -0.68em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.32em;"><span style="top: -2.31em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">4</span></span></span><span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span style="top: -3.67em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.68em;"></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">∗</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathdefault" style="margin-right: 0.01em;">l</span><span class="mord mathdefault">o</span><span class="mord mathdefault" style="margin-right: 0.03em;">g</span><span class="mopen">(</span><span class="mord">4</span><span class="mclose">)</span><span class="mspace" style="margin-right: 0.27em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.27em;"></span></span><span class="base"><span class="strut" style="height: 0.64em; vertical-align: 0em;"></span><span class="mord">2</span></span></span></span></span></span><br> (这里我们把符号直接化进log中了)</p>
大家发现没有,log(x)是不是恰巧等于x需要询问的次数呢?!!!这也是这个公式的精妙所在,在离散数学中我们学过,一个树的高度等于log(节点数),这个log(x)恰巧是询问的高度,也就是投硬币的次数!这原来就是使用log的原因
上面的例子中A,B,C,D都是等概率出现的;下面我们将这个过程一般化,看一看当每个随机变量不等概率时的运算过程
我们看如上的序列,其中A出现的概率要等于BCD之和。所以我们为了让我们的提问次数最小化,我们要尽力讲每次提问的YorN分成等概率,也就是我们要问的第一个问题是:
Q1:这个字符是A吗?
如果不是,我们知道是B,C,D但是B的概率等于C和D之和,我们就再问:
Q2:这个字符是B吗?
如果不是,这时候C和D等概率,我们随便问一个即可:
Q3:这个字符是C吗?
好了,现在得出了结论。
问出A需要1次,B2次,C和D都是三次。
我们用信息熵来计算一下。
H
(
x
)
=
1
2
∗
l
o
g
(
2
)
+
1
4
∗
l
o
g
(
4
)
+
1
8
∗
l
o
g
(
8
)
+
1
8
∗
l
o
g
(
8
)
H(x)=\frac{1}{2}*log(2)+\frac{1}{4}*log(4)+\frac{1}{8}*log(8)+\frac{1}{8}*log(8)
</span><span class="katex-html"><span class="base"><span class="strut" style="height: 0.68em; vertical-align: 0em;"></span><span class="mord mathdefault" style="margin-right: 0.08em;">H</span><span class="mord cjk_fallback">(</span><span class="mord mathdefault">x</span><span class="mord cjk_fallback">)</span><span class="mspace" style="margin-right: 0.27em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.27em;"></span></span><span class="base"><span class="strut" style="height: 2em; vertical-align: -0.68em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.32em;"><span style="top: -2.31em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span style="top: -3.67em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.68em;"></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">∗</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathdefault" style="margin-right: 0.01em;">l</span><span class="mord mathdefault">o</span><span class="mord mathdefault" style="margin-right: 0.03em;">g</span><span class="mopen">(</span><span class="mord">2</span><span class="mclose">)</span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 2em; vertical-align: -0.68em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.32em;"><span style="top: -2.31em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">4</span></span></span><span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span style="top: -3.67em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.68em;"></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">∗</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathdefault" style="margin-right: 0.01em;">l</span><span class="mord mathdefault">o</span><span class="mord mathdefault" style="margin-right: 0.03em;">g</span><span class="mopen">(</span><span class="mord">4</span><span class="mclose">)</span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 2em; vertical-align: -0.68em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.32em;"><span style="top: -2.31em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">8</span></span></span><span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span style="top: -3.67em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.68em;"></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">∗</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathdefault" style="margin-right: 0.01em;">l</span><span class="mord mathdefault">o</span><span class="mord mathdefault" style="margin-right: 0.03em;">g</span><span class="mopen">(</span><span class="mord">8</span><span class="mclose">)</span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 2em; vertical-align: -0.68em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.32em;"><span style="top: -2.31em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">8</span></span></span><span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span style="top: -3.67em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height: 0.68em;"></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.22em;"></span><span class="mbin">∗</span><span class="mspace" style="margin-right: 0.22em;"></span></span><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathdefault" style="margin-right: 0.01em;">l</span><span class="mord mathdefault">o</span><span class="mord mathdefault" style="margin-right: 0.03em;">g</span><span class="mopen">(</span><span class="mord">8</span><span class="mclose">)</span></span></span></span></span></span><br> 每一个log(x)恰巧对应着他所在的叶子在树的第几层,也就是他需要询问的次数,前面乘上一个概率,是不是发现这个公式提出的非常巧妙!!</p>
同时,在二进制计算机中,一个比特为0或1,其实就代表了一个二元问题的回答。也就是说,在计算机中,对于这个事件进行编码,所需要的平均码长为H(x)个比特。
三、结语
通过上述过程,相信大家能清楚的理解信息熵。本文并没有一些数学上详细的证明,暂时留个坑以后填。如果大家有什么问题,欢迎在评论区交流,如果觉得有用麻烦点个赞~
参考资料:
[1]https://www.youtube.com/watch?v=ErfnhcEV1O8
[2]https://blog.csdn.net/v_JULY_v/article/details/40508465
假设数据集有m行,即m个样本,每一行最后一列为该样本的标签,计算数据集信息熵的代码如下:
from math import log
def calcShannonEnt(dataSet):
numEntries = len(dataSet) # 样本数
labelCounts = {} # 该数据集每个类别的频数
for featVec in dataSet: # 对每一行样本
currentLabel = featVec[-1] # 该样本的标签
if currentLabel not in labelC
<textarea class="comment-content" name="comment_content" id="comment_content" placeholder="优质评论可以帮助作者获得更高权重" maxlength="1000"></textarea>
<div class="comment-emoticon"><img class="comment-emoticon-img" data-url="https://csdnimg.cn/release/blogv2/dist/pc/img/" src="https://csdnimg.cn/release/blogv2/dist/pc/img/emoticon.png" alt="表情包"></div>
<span class="comment-emoticon-tip">插入表情</span>
<div class="comment-emoticon-box" style="display: none;">
<div class="comment-emoticon-img-box">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:001.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/001.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:002.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/002.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:003.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/003.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:004.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/004.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:005.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/005.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:006.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/006.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:007.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/007.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:008.png[/face]" src="https://i-blog.csdnimg.cn/blog_migrate/27c20afc0e17c9b94fdf931b1b2a13f0.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:009.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/009.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:010.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/010.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:011.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/011.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:012.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/012.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:013.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/013.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:014.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/014.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:015.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/015.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:016.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/016.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:017.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/017.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:018.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/018.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:019.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/019.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:020.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/020.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:021.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/021.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:022.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/022.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:023.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/023.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:024.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/024.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:025.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/025.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:026.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/026.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:027.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/027.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:028.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/028.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:029.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/029.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:030.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/030.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:031.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/031.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:032.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/032.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:033.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/033.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:034.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/034.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:035.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/035.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:036.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/036.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:037.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/037.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:038.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/038.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:039.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/039.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:040.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/040.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:041.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/041.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:042.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/042.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:043.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/043.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:044.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/044.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:045.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/045.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:046.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/046.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:047.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/047.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:048.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/048.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:049.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/049.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:050.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/050.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:051.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/051.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:052.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/052.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:053.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/053.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:054.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/054.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:055.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/055.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:056.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/056.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:057.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/057.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:058.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/058.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:059.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/059.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:060.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/060.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:061.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/061.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:062.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/062.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:063.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/063.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:064.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/064.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:065.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/065.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:066.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/066.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:067.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/067.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:068.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/068.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:069.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/069.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:070.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/070.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:071.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/071.png">
<img class="emoticon-monkey-img" data-emoticon="[face]emoji:072.png[/face]" src="https://g.csdnimg.cn/static/face/emoji/072.png">
</div>
</div>
<div class="opt-box">
<div id="ubbtools" class="add_code">
<a href="#insertcode" code="code" target="_self"><i class="icon iconfont icon-daima"></i></a>
</div>
<input type="hidden" id="comment_replyId" name="comment_replyId">
<input type="hidden" id="article_id" name="article_id" value="105704098">
<input type="hidden" id="comment_userId" name="comment_userId" value="">
<input type="hidden" id="commentId" name="commentId" value="">
<div class="dropdown" id="myDrap">
<a class="dropdown-face d-flex align-items-center" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<div class="txt-selected text-truncate">添加代码片</div>
<svg class="icon d-block" width="200px" height="100.00px" viewBox="0 0 2048 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M597.33333292 298.666667h853.333334L1023.99999992 725.333333 597.33333292 298.666667z"></path></svg>
</a>
<ul class="dropdown-menu" id="commentCode" aria-labelledby="drop4">
<li><a data-code="html">HTML/XML</a></li>
<li><a data-code="objc">objective-c</a></li>
<li><a data-code="ruby">Ruby</a></li>
<li><a data-code="php">PHP</a></li>
<li><a data-code="csharp">C</a></li>
<li><a data-code="cpp">C++</a></li>
<li><a data-code="javascript">JavaScript</a></li>
<li><a data-code="python">Python</a></li>
<li><a data-code="java">Java</a></li>
<li><a data-code="css">CSS</a></li>
<li><a data-code="sql">SQL</a></li>
<li><a data-code="plain">其它</a></li>
</ul>
</div>
<div class="right-box" id="rightBox" data-type="2">
<span id="tip_comment" class="tip">还能输入<em>1000</em>个字符</span>
<a data-report-click="{"mod":"1582594662_003","spm":"1001.2101.3001.4227","ab":"new"}"><input type="submit" class="btn btn-sm btn-comment" value="发表评论"></a>
</div>
</div>
</form>
<input type="button" class="bt-comment-show" value="评论">
</div>
<div class="comment-list-container" style="display: block;">
<a id="comments"></a>
<div class="comment-list-box"><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="15235812" data-replyname="FlappyCD"><div style="display: flex;width: 100%;"> <a target="_blank" href="https://blog.csdn.net/FlappyCD"><img src="https://profile.csdnimg.cn/0/D/9/3_flappycd" username="FlappyCD" alt="FlappyCD" class="avatar"></a> <div class="right-box "> <div class="new-info-box clearfix"> <a target="_blank" href="https://blog.csdn.net/FlappyCD"><span class="name ">FlappyCD</span></a><span class="colon">:</span><span class="floor-num"></span><span class="new-comment">支持</span><span class="date" title="2021-03-03 17:32:58">4 月前</span><span class="new-opt-floating"><a class="btn-bt btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt btn-report"><img class="btn-report-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentMore.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="15235812"><img class="comment-like-img unclickImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentUnHeart.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><img class="comment-like-img clickedImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><span>1</span></div></div></div></li><li class="replay-box" style="display:block"><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="16934220" data-replyname="qq_35624030"><div style="display: flex;width: 100%;"> <a target="_blank" href="https://blog.csdn.net/qq_35624030"><img src="https://profile.csdnimg.cn/7/5/3/3_qq_35624030" username="qq_35624030" alt="qq_35624030" class="avatar"></a> <div class="right-box "> <div class="new-info-box clearfix"> <a target="_blank" href="https://blog.csdn.net/qq_35624030"><span class="name mr-8">StudentWang_<img class="is_bloger" src="https://csdnimg.cn/release/blogv2/dist/components/img/bloger@2x.png"></span></a><span class="text">回复</span><span class="colon">:</span><span class="text"></span><span class="new-comment">感谢支持</span><span class="date" title="2021-06-10 13:10:11">1 月前</span><span class="new-opt-floating"><a class="btn-bt btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt btn-report"><img class="btn-report-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentMore.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="16934220"><img class="comment-like-img unclickImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentUnHeart.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><img class="comment-like-img clickedImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><span></span></div></div></div></li><li class="comment-line-box d-flex" data-commentid="15377818" data-replyname="qq_35624030"><div style="display: flex;width: 100%;"> <a target="_blank" href="https://blog.csdn.net/qq_35624030"><img src="https://profile.csdnimg.cn/7/5/3/3_qq_35624030" username="qq_35624030" alt="qq_35624030" class="avatar"></a> <div class="right-box "> <div class="new-info-box clearfix"> <a target="_blank" href="https://blog.csdn.net/qq_35624030"><span class="name mr-8">StudentWang_<img class="is_bloger" src="https://csdnimg.cn/release/blogv2/dist/components/img/bloger@2x.png"></span></a><span class="text">回复</span><span class="colon">:</span><span class="text"></span><span class="new-comment">非常感谢!</span><span class="date" title="2021-03-11 19:13:35">4 月前</span><span class="new-opt-floating"><a class="btn-bt btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt btn-report"><img class="btn-report-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentMore.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="15377818"><img class="comment-like-img unclickImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentUnHeart.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><img class="comment-like-img clickedImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><span></span></div></div></div></li></ul></li></ul><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="12002481" data-replyname="m0_37422217"><div style="display: flex;width: 100%;"> <a target="_blank" href="https://blog.csdn.net/m0_37422217"><img src="https://profile.csdnimg.cn/B/2/A/3_m0_37422217" username="m0_37422217" alt="m0_37422217" class="avatar"></a> <div class="right-box "> <div class="new-info-box clearfix"> <a target="_blank" href="https://blog.csdn.net/m0_37422217"><span class="name ">安财小山羊</span></a><span class="colon">:</span><span class="floor-num"></span><span class="new-comment">写的很棒,很有收获</span><span class="date" title="2020-04-24 12:52:44">1 年前</span><span class="new-opt-floating"><a class="btn-bt btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt btn-report"><img class="btn-report-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentMore.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="12002481"><img class="comment-like-img unclickImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentUnHeart.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><img class="comment-like-img clickedImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><span>1</span></div></div></div></li><li class="replay-box" style="display:block"><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="12002566" data-replyname="qq_35624030"><div style="display: flex;width: 100%;"> <a target="_blank" href="https://blog.csdn.net/qq_35624030"><img src="https://profile.csdnimg.cn/7/5/3/3_qq_35624030" username="qq_35624030" alt="qq_35624030" class="avatar"></a> <div class="right-box reply-box"> <div class="new-info-box clearfix"> <a target="_blank" href="https://blog.csdn.net/qq_35624030"><span class="name mr-8">StudentWang_<img class="is_bloger" src="https://csdnimg.cn/release/blogv2/dist/components/img/bloger@2x.png"></span></a><span class="text">回复</span><span class="colon">:</span><span class="text"></span><span class="new-comment">感谢支持</span><span class="date" title="2020-04-24 13:02:36">1 年前</span><span class="new-opt-floating"><a class="btn-bt btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt btn-report"><img class="btn-report-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentMore.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="12002566"><img class="comment-like-img unclickImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentUnHeart.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><img class="comment-like-img clickedImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><span></span></div></div></div></li></ul></li></ul><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="17648755" data-replyname="m0_52402667"><div style="display: flex;width: 100%;"> <a target="_blank" href="https://blog.csdn.net/m0_52402667"><img src="https://profile.csdnimg.cn/5/D/0/3_m0_52402667" username="m0_52402667" alt="m0_52402667" class="avatar"></a> <div class="right-box "> <div class="new-info-box clearfix"> <a target="_blank" href="https://blog.csdn.net/m0_52402667"><span class="name ">2002小雨点</span></a><span class="colon">:</span><span class="floor-num"></span><span class="new-comment">感谢博主,解释的很清晰</span><span class="date" title="2021-07-22 16:10:49">24 分钟前</span><span class="new-opt-floating"><a class="btn-bt btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt btn-report"><img class="btn-report-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentMore.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="17648755"><img class="comment-like-img unclickImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentUnHeart.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><img class="comment-like-img clickedImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><span></span></div></div></div></li></ul><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="16800273" data-replyname="qq_45704942"><div style="display: flex;width: 100%;"> <a target="_blank" href="https://blog.csdn.net/qq_45704942"><img src="https://profile.csdnimg.cn/4/9/2/3_qq_45704942" username="qq_45704942" alt="qq_45704942" class="avatar"></a> <div class="right-box "> <div class="new-info-box clearfix"> <a target="_blank" href="https://blog.csdn.net/qq_45704942"><span class="name ">敲代码的小提琴手</span></a><span class="colon">:</span><span class="floor-num"></span><span class="new-comment">这个决策树的引出 妙啊<img src="//g.csdnimg.cn/static/face/emoji/003.png" alt="表情包"></span><span class="date" title="2021-06-03 13:07:39">1 月前</span><span class="new-opt-floating"><a class="btn-bt btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt btn-report"><img class="btn-report-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentMore.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="16800273"><img class="comment-like-img unclickImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentUnHeart.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><img class="comment-like-img clickedImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><span></span></div></div></div></li><li class="replay-box" style="display:block"><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="16850280" data-replyname="qq_35624030"><div style="display: flex;width: 100%;"> <a target="_blank" href="https://blog.csdn.net/qq_35624030"><img src="https://profile.csdnimg.cn/7/5/3/3_qq_35624030" username="qq_35624030" alt="qq_35624030" class="avatar"></a> <div class="right-box "> <div class="new-info-box clearfix"> <a target="_blank" href="https://blog.csdn.net/qq_35624030"><span class="name mr-8">StudentWang_<img class="is_bloger" src="https://csdnimg.cn/release/blogv2/dist/components/img/bloger@2x.png"></span></a><span class="text">回复</span><span class="colon">:</span><span class="text"></span><span class="new-comment">感谢支持</span><span class="date" title="2021-06-06 10:13:34">1 月前</span><span class="new-opt-floating"><a class="btn-bt btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt btn-report"><img class="btn-report-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentMore.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="16850280"><img class="comment-like-img unclickImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentUnHeart.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><img class="comment-like-img clickedImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><span></span></div></div></div></li></ul></li></ul><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="15931033" data-replyname="qq_42018029"><div style="display: flex;width: 100%;"> <a target="_blank" href="https://blog.csdn.net/qq_42018029"><img src="https://profile.csdnimg.cn/F/9/C/3_qq_42018029" username="qq_42018029" alt="qq_42018029" class="avatar"></a> <div class="right-box "> <div class="new-info-box clearfix"> <a target="_blank" href="https://blog.csdn.net/qq_42018029"><span class="name ">6qishi</span></a><span class="colon">:</span><span class="floor-num"></span><span class="new-comment">谢谢作者,一下就搞明白了<img src="//g.csdnimg.cn/static/face/monkey2/003.png" alt="表情包"></span><span class="date" title="2021-04-14 21:15:53">3 月前</span><span class="new-opt-floating"><a class="btn-bt btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt btn-report"><img class="btn-report-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentMore.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="15931033"><img class="comment-like-img unclickImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentUnHeart.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><img class="comment-like-img clickedImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><span></span></div></div></div></li><li class="replay-box" style="display:block"><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="15948388" data-replyname="qq_35624030"><div style="display: flex;width: 100%;"> <a target="_blank" href="https://blog.csdn.net/qq_35624030"><img src="https://profile.csdnimg.cn/7/5/3/3_qq_35624030" username="qq_35624030" alt="qq_35624030" class="avatar"></a> <div class="right-box "> <div class="new-info-box clearfix"> <a target="_blank" href="https://blog.csdn.net/qq_35624030"><span class="name mr-8">StudentWang_<img class="is_bloger" src="https://csdnimg.cn/release/blogv2/dist/components/img/bloger@2x.png"></span></a><span class="text">回复</span><span class="colon">:</span><span class="text"></span><span class="new-comment">能帮到你就很好了~加油</span><span class="date" title="2021-04-15 20:51:20">3 月前</span><span class="new-opt-floating"><a class="btn-bt btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt btn-report"><img class="btn-report-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentMore.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="15948388"><img class="comment-like-img unclickImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentUnHeart.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><img class="comment-like-img clickedImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><span></span></div></div></div></li></ul></li></ul><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="15588525" data-replyname="qinghuanduji"><div style="display: flex;width: 100%;"> <a target="_blank" href="https://blog.csdn.net/qinghuanduji"><img src="https://profile.csdnimg.cn/2/0/9/3_qinghuanduji" username="qinghuanduji" alt="qinghuanduji" class="avatar"></a> <div class="right-box "> <div class="new-info-box clearfix"> <a target="_blank" href="https://blog.csdn.net/qinghuanduji"><span class="name ">人间不想清醒</span></a><span class="colon">:</span><span class="floor-num"></span><span class="new-comment">博主太强了,解释的很清楚,小白想请教一下比如排列熵这些是不是信息熵的一种呀,该怎么查找这些熵资料呢(感觉都无从获得不同熵的名字来进行查找)</span><span class="date" title="2021-03-24 16:07:28">4 月前</span><span class="new-opt-floating"><a class="btn-bt btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt btn-report"><img class="btn-report-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentMore.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="15588525"><img class="comment-like-img unclickImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentUnHeart.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><img class="comment-like-img clickedImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><span></span></div></div></div></li><li class="replay-box" style="display:block"><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="15887145" data-replyname="qinghuanduji"><div style="display: flex;width: 100%;"> <a target="_blank" href="https://blog.csdn.net/qinghuanduji"><img src="https://profile.csdnimg.cn/2/0/9/3_qinghuanduji" username="qinghuanduji" alt="qinghuanduji" class="avatar"></a> <div class="right-box "> <div class="new-info-box clearfix"> <a target="_blank" href="https://blog.csdn.net/qinghuanduji"><span class="name mr-8">人间不想清醒</span></a><span class="text">回复</span><span class="nick-name">Zhi Zhao</span><span class="colon">:</span><span class="text"></span><span class="new-comment">马上到,大佬<img src="//g.csdnimg.cn/static/face/monkey2/002.png" alt="表情包"></span><span class="date" title="2021-04-12 15:45:05">3 月前</span><span class="new-opt-floating"><a class="btn-bt btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt btn-report"><img class="btn-report-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentMore.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="15887145"><img class="comment-like-img unclickImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentUnHeart.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><img class="comment-like-img clickedImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><span></span></div></div></div></li><li class="comment-line-box d-flex" data-commentid="15878833" data-replyname="weixin_45317919"><div style="display: flex;width: 100%;"> <a target="_blank" href="https://blog.csdn.net/weixin_45317919"><img src="https://profile.csdnimg.cn/D/3/8/3_weixin_45317919" username="weixin_45317919" alt="weixin_45317919" class="avatar"></a> <div class="right-box "> <div class="new-info-box clearfix"> <a target="_blank" href="https://blog.csdn.net/weixin_45317919"><span class="name mr-8">Zhi Zhao</span></a><span class="text">回复</span><span class="colon">:</span><span class="text"></span><span class="new-comment">来我的主页看看吧<img src="//g.csdnimg.cn/static/face/monkey2/004.png" alt="表情包">,有各种熵的讲解</span><span class="date" title="2021-04-12 07:59:26">3 月前</span><span class="new-opt-floating"><a class="btn-bt btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt btn-report"><img class="btn-report-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentMore.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="15878833"><img class="comment-like-img unclickImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentUnHeart.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><img class="comment-like-img clickedImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><span></span></div></div></div></li><li class="comment-line-box d-flex" data-commentid="15593056" data-replyname="qinghuanduji"><div style="display: flex;width: 100%;"> <a target="_blank" href="https://blog.csdn.net/qinghuanduji"><img src="https://profile.csdnimg.cn/2/0/9/3_qinghuanduji" username="qinghuanduji" alt="qinghuanduji" class="avatar"></a> <div class="right-box "> <div class="new-info-box clearfix"> <a target="_blank" href="https://blog.csdn.net/qinghuanduji"><span class="name mr-8">人间不想清醒</span></a><span class="text">回复</span><span class="nick-name">StudentWang_</span><span class="colon">:</span><span class="text"></span><span class="new-comment">好的,谢谢博主的回复</span><span class="date" title="2021-03-24 20:35:44">4 月前</span><span class="new-opt-floating"><a class="btn-bt btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt btn-report"><img class="btn-report-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentMore.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="15593056"><img class="comment-like-img unclickImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentUnHeart.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><img class="comment-like-img clickedImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><span></span></div></div></div></li><li class="comment-line-box d-flex" data-commentid="15590387" data-replyname="qq_35624030"><div style="display: flex;width: 100%;"> <a target="_blank" href="https://blog.csdn.net/qq_35624030"><img src="https://profile.csdnimg.cn/7/5/3/3_qq_35624030" username="qq_35624030" alt="qq_35624030" class="avatar"></a> <div class="right-box "> <div class="new-info-box clearfix"> <a target="_blank" href="https://blog.csdn.net/qq_35624030"><span class="name mr-8">StudentWang_<img class="is_bloger" src="https://csdnimg.cn/release/blogv2/dist/components/img/bloger@2x.png"></span></a><span class="text">回复</span><span class="colon">:</span><span class="text"></span><span class="new-comment">不好意思哈。我本身并不是做这块的,只是用到了信息熵所以学了一下。对于信息论的这些并不是很清楚,可以看看知乎、CSDN上其他博主的学习路线</span><span class="date" title="2021-03-24 17:28:23">4 月前</span><span class="new-opt-floating"><a class="btn-bt btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt btn-report"><img class="btn-report-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentMore.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="15590387"><img class="comment-like-img unclickImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentUnHeart.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><img class="comment-like-img clickedImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><span></span></div></div></div></li></ul></li></ul><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="15515215" data-replyname="Java_Development_Kit"><div style="display: flex;width: 100%;"> <a target="_blank" href="https://blog.csdn.net/Java_Development_Kit"><img src="https://profile.csdnimg.cn/E/E/E/3_java_development_kit" username="Java_Development_Kit" alt="Java_Development_Kit" class="avatar"></a> <div class="right-box "> <div class="new-info-box clearfix"> <a target="_blank" href="https://blog.csdn.net/Java_Development_Kit"><span class="name ">原来很简单</span></a><span class="colon">:</span><span class="floor-num"></span><span class="new-comment">这个公式妙啊<img src="//g.csdnimg.cn/static/face/monkey2/057.png" alt="表情包"></span><span class="date" title="2021-03-19 19:16:48">4 月前</span><span class="new-opt-floating"><a class="btn-bt btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt btn-report"><img class="btn-report-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentMore.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="15515215"><img class="comment-like-img unclickImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentUnHeart.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><img class="comment-like-img clickedImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><span></span></div></div></div></li><li class="replay-box" style="display:block"><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="15590365" data-replyname="qq_35624030"><div style="display: flex;width: 100%;"> <a target="_blank" href="https://blog.csdn.net/qq_35624030"><img src="https://profile.csdnimg.cn/7/5/3/3_qq_35624030" username="qq_35624030" alt="qq_35624030" class="avatar"></a> <div class="right-box "> <div class="new-info-box clearfix"> <a target="_blank" href="https://blog.csdn.net/qq_35624030"><span class="name mr-8">StudentWang_<img class="is_bloger" src="https://csdnimg.cn/release/blogv2/dist/components/img/bloger@2x.png"></span></a><span class="text">回复</span><span class="colon">:</span><span class="text"></span><span class="new-comment">是的~细细品味很有意思</span><span class="date" title="2021-03-24 17:27:38">4 月前</span><span class="new-opt-floating"><a class="btn-bt btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt btn-report"><img class="btn-report-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentMore.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="15590365"><img class="comment-like-img unclickImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentUnHeart.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><img class="comment-like-img clickedImg" src="https://csdnimg.cn/release/blogv2/dist/pc/img/commentActiveHeart.png" title="点赞"><span></span></div></div></div></li></ul></li></ul></div>
<div id="commentPage" class="pagination-box d-none" style="display: block;"><div id="Paging_04570656664931554" class="ui-paging-container"><ul><li class="js-page-first js-page-action ui-pager ui-pager-disabled"></li><li class="js-page-prev js-page-action ui-pager ui-pager-disabled"><</li><li data-page="1" class="ui-pager focus">1</li><li class="js-page-next js-page-action ui-pager ui-pager-disabled">></li><li class="js-page-last js-page-action ui-pager ui-pager-disabled"></li></ul></div></div>
</div>
先抛出信息熵公式如下:
其中P(xi)代表随机事件X为xi的概率,下面来逐步介绍信息熵的公式来源!
2 信息量
信息量是对信息的度量,就跟时间的度量是秒一样,当我们考虑一个离散的随机变量x的时候,当我们观察到的这个变量的一个具体值的时候,我们接收到了多少信息呢?
多少信息用信息量来衡
n枚硬币,可能有一枚假币,…
但信息可不可以被量化,怎样量化?答案当然是有的,那就是“信息熵”。早在1948年,香农(Shannon)在他著名的《通信的数学原理》论文中指出:“信息是用来消除随机不确定性的东西”,并提出了“信息熵”的概念(借用了热力学中熵的概念),来解
一.决策树
二.信息熵
三.基尼系数
四.CART与超参数
五.决策树解决回归问题
一.决策树
决策树(Decision Tree)是在已知各种情况发生概率的基础上,通过构成决策树来求取净现值的期望值大于等于零的概率,评价项目风险,判断其可行性的决策分析方法,是直观运用概率分析的一种图解法。
sklearn中调用决策树
from sklearn.tree import De…
信息
前几天虽然看完了吴军先生的《数学之美》,但一直搞不懂信息熵所以连带着也没搞懂 最大熵的原理,直到今天白天看了TopLanguage的一个讨论信息论的帖子
再经过晚上散步时思考才顿悟信息熵的意义。
信息是个很抽象的概念。人们常常说信息很多,或者信息较少,但却很难说清楚信息到底有多少。比如一本五十万字的中文书到底有多少信息量…
这篇文章主要讲:熵, 联合熵(joint entropy),条件熵(conditional entropy),相对熵(relative entropy,KL 距离),互信息(mutual information),交叉熵(cross entropy),困惑度(perplexity)。
…
1 混乱的熵
很多科普文章中,都提到熵是用来度量混乱的。比如下面这幅动图,单词“Entropy”(熵的英文)可见的时候,熵最小,这个时候最有秩序;而被打乱的时候,熵开始增大,直到最后一片混乱,熵变成最大:
熵之所以很重要,是因为它总结了宇宙…
2002小雨点: 感谢博主,解释的很清晰
曼舞精灵: 加油,我也要上道了
自演乙丶: 我的邮箱是2464123186@qq.com 谢谢学长
自演乙丶: 学长你好 能分享一下三门的ppt么
weixin_39680581: X86指针4字节,X64指针8字节