信息熵越大表示所含信息量越多
Entropy
01 Syntax
Microsoft.VisualBasic.Math.Information.Entropy
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| ShannonEnt | 1 | 计算出目标序列的香农信息熵 |
| ShannonEntropy | 1 | Calculate entropy value. |
| Gini | 1 | 基尼系数的选择的标准就是每个子节点达到最高的纯度,即落在子节点中的所有观察都属于同一个分类, 此时基尼系数最小,纯度最高,不确定度最小。 基尼指数越大,说明不确定性就越大;基尼系数越小,不确定性越小,数据分割越彻底,越干净。 |
| ShannonEnt | 1 |
03 Members
ShannonEnt``1(
IEnumerable(Of ``0))计算出目标序列的香农信息熵
Remarks
计算公式
H(x) = E[ I(xi) ]
= E[ log(2, 1/p(xi)) ]
= -∑ p(xi)log(2, p(xi)) (i=1, 2, ..., n)
其中,x表示随机变量,与之相对应的是所有可能输出的集合,定义为符号集,随机变量的输出用x表示。 P(x)表示输出概率函数。变量的不确定性越大,熵也就越大,把它搞清楚所需要的信息量也就越大.
Type Parameters
| Name | Description |
|---|---|
T |
Parameters
| Name | Type | Description |
|---|---|---|
collection | IEnumerable(Of ``0) | - |
ShannonEntropy(
IEnumerable(Of Double))Calculate entropy value.
(直接从一个概率向量之中计算出香农信息熵)
Remarks
The input array is treated as histogram, i.e. its indexes are treated as values of stochastic function, but array values are treated as "probabilities" (total amount of hits).
Sample usage:
// create histogram array with 2 values of equal probabilities
int[] histogram1 = new int[2] { 3, 3 };
// calculate entropy
double entropy1 = Statistics.Entropy( histogram1 );
// output it (1.000)
Console.WriteLine( "entropy1 = " + entropy1.ToString( "F3" ) );
// create histogram array with 4 values of equal probabilities
int[] histogram2 = new int[4] { 1, 1, 1, 1 };
// calculate entropy
double entropy2 = Statistics.Entropy( histogram2 );
// output it (2.000)
Console.WriteLine( "entropy2 = " + entropy2.ToString( "F3" ) );
// create histogram array with 4 values of different probabilities
int[] histogram3 = new int[4] { 1, 2, 3, 4 };
// calculate entropy
double entropy3 = Statistics.Entropy( histogram3 );
// output it (1.846)
Console.WriteLine( "entropy3 = " + entropy3.ToString( "F3" ) );
Parameters
| Name | Type | Description |
|---|---|---|
probs | IEnumerable(Of Double) | Sum of this probability vector must equals to 1, Histogram array. |
Gini(
IEnumerable(Of Double))基尼系数的选择的标准就是每个子节点达到最高的纯度,即落在子节点中的所有观察都属于同一个分类, 此时基尼系数最小,纯度最高,不确定度最小。
基尼指数越大,说明不确定性就越大;基尼系数越小,不确定性越小,数据分割越彻底,越干净。
Parameters
| Name | Type | Description |
|---|---|---|
p | IEnumerable(Of Double) | the data probability |
ShannonEnt(
IEnumerable(Of T))