快速香农熵计算 [英] Fast Shannon Entropy Calculation

查看:135
本文介绍了快速香农熵计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种快速的方法来计算16位数字缓冲区的香农熵,而无需计算每个频率计数的log2?日志计算非常慢.

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.

推荐答案

好的,答案是,不计算log函数就无法做到这一点,但是如果您预先计算日志,那还不错

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.

我的缓冲区的大小为4096字节,因此每个可能的2字节值在1..2048之间.因此,需要预先计算1/2048 .. 2048/2048的对数.那么每个日志的计算只是一个数组查找.

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.

这篇关于快速香农熵计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆