聯合熵我有兩個數組: 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