联合熵我有两个数组: import numpy as np
a = np.array(['1','2','3'])
b = np.array(['3','4','1','5'])
我想计算联合熵。我发现一些材料,使它象: import numpy as np
def entropy(*X):
return = np.sum(-p * np.log2(p) if p > 0 el
如果我估计使用MATLAB entropy()函数标准正态随机变量的矢量的熵,我得到某处的4区域中的答案,而actual entropy应该0.5 * log(2*pi*e*sigma^2)这是大约等于1.4。 有没有人知道差异来自哪里? 注:到这里节省时间就是Matlab代码 for i = 1:1000
X(i) = randn();
end
'The entropy of X
这里就是我用我的程序代码: calcHist(&pre_img, 1, channels, Mat(), // do not use mask
hist, 1, histSize, ranges,
true, // the histogram is uniform
false);
Mat histNorm = hist/(pre_img