Fast Shannon Entropy Calculation

ぃ、小莉子 提交于 2019-12-08 12:00:04

问题


Is there a fast way to calculate shannon entropy of a buffer of 16-bit numbers without having the calculate the log2 of every frequency count? The log calculations are quite slow.


回答1:


Okay, so the answer is that there is no way to do it without calculating the log function, but if you pre-calculate the logs, it's not so bad.

My buffer is 4096 bytes in size, so there are between 1..2048 of each possible 2-byte value. So the logs of 1/2048 .. 2048/2048 need to be pre-calculated. Then the calculation of each log is just an array lookup.



来源:https://stackoverflow.com/questions/28127433/fast-shannon-entropy-calculation

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