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
评论列表
文章目录