📅  最后修改于: 2022-03-11 14:45:55.657000             🧑  作者: Mango
import math
def entropy_cal(array):
total_entropy = 0
for i in array:
total_entropy += -i * math.log(2, i)
return total_entropy
def main():
probabilities = [0.5, 0.5]
entropy = entropy_cal(probabilities)
print(entropy)