entropy estimation using histogram of normal data vs direct formula (matlab)

孤街浪徒 提交于 2019-12-05 17:20:21

You are missing the dp term in the sum

dp = (x(2)-x(1));
area = sum(p)*dp;
H = -sum( (p*dp) * log2(p) );

This should bring you close enough...

PS,
be careful when you take log2(p) for sometimes you might have empty bins. You might find nansum useful.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!