计算a, b的entropy
import numpy as np
import scipy.stats as stats
a = [0.8, 0.15, 0.05]
b = [0.5, 0.3, 0.2]
a = np.asarray(a)
b = np.asarray(b)
print(stats.entropy(a))
print(stats.entropy(b))
结果是:
0.6128694524619495
1.0296530140645737
说明b的entropy更高。
再次计算
import numpy as np
import scipy.stats as stats
a = [0.1, 0.1, 0.9, 0.8, 0.1]
b = [0.9, 0.9, 0.8, 0.9, 0.8]
c = [0.1, 0.1, 0.2, 0.1, 0.1]
a = np.asarray(a)
b = np.asarray(b)
print(stats.entropy(a))
print(stats.entropy(b))
print(stats.entropy(c))
结果是:
1.1752045970807579
1.6078017841829741
1.5607104090414068
问题:
- 方差和entropy成反比?
- entropy和KL divergence是什么关系?
网友评论