entropy.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:leven-squash 作者: dwcoates 项目源码 文件源码
def get_entropy(self, probs):
        """
        Estimate the entropy of string in Shannons. That is, this method
        assumes that the frequency of characters in the input string is
        exactly equal to the probability mass function.
        """
        # calculates entropy in Nats
        ent_nat = entropy(probs)

        # convert to Shannons
        ent_shan = ent_nat * 1 / np.log(2)

        return ent_shan
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号