📜  熵公式 pyhon - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:55.657000             🧑  作者: Mango

代码示例1
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)