Python中关于联合熵的熵计算

2024-09-30 12:30:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我想写一个函数来计算关节- 给定两个通用离散随机变量的联合p.d.f.。这是一种合法的方法吗

probX = 0.5
probY = 0.5

def joint_entropy(probs):
    information = np.sum([pdf * math.log(1/pdf, 2) for pdf in probs])
    return(information)
    
joint_entropy([probX, probY])


Tags: 方法函数informationpdfdefnpmathentropy

热门问题