How to calculate the entropy of a file?

前端 未结 11 1336
野趣味
野趣味 2020-11-28 20:16

How to calculate the entropy of a file? (Or let\'s just say a bunch of bytes)
I have an idea, but I\'m not sure that it\'s mathematically correct.

My id

11条回答
  •  鱼传尺愫
    2020-11-28 20:59

    If you use information theory entropy, mind that it might make sense not to use it on bytes. Say, if your data consists of floats you should instead fit a probability distribution to those floats and calculate the entropy of that distribution.

    Or, if the contents of the file is unicode characters, you should use those, etc.

提交回复
热议问题