i) is very much smaller than at least one other model's data probability. In this case it can happen that P(M

问题描述 投票:0回答:1

我正在尝试实现以下内容。

enter image description here

右边的部分返回0和1之间的概率. 各文件 注:由于概率乘积的数值精度问题,在我们的实施中,我们遵循通常的做法,使用对数概率相加。

由于概率乘积的数值精度问题,在我们的实施中,我们遵循通常的做法,使用对数概率之和。

根据我的理解,使用对数概率之和有助于防止下溢。但是我就没有得到0和1之间的值,上面公式中的1-也没有意义。我在这里遗漏了什么?我可以将对数概率之和转换回0和1之间的值吗?当使用大量的概率时,我得到的仍然是一个很小的数字,例如:。

log_probability = math.log(0.9) + math.log(0.3) + math.log(0.9) + math.log(1) + math.log(0.9) + math.log(0.3) + math.log(0.3) + math.log(0.3) + math.log(0.3) + math.log(0.3) + math.log(0.3) + math.log(0.3) + math.log(0.3) + math.log(0.3) + math.log(0.3) + math.log(0.3) + math.log(0.3) 
prob = math.exp(log_probability)

例如: log_probality=-15.967728003210647prob =1.1622614669999998e-07.

谢谢你,我对统计学的理解真的到了边缘......!

python statistics probability
1个回答
0
投票

在我看来,要避免的是作为浮点数的概率变为零,而作为实数的概率则不是。我们的策略是将概率作为其对数进行存储和处理,并在需要时将其转换为真正的概率。

一个例子可能会让这个问题更清楚。假设我们有N个数据模型,我们试图将概率赋予模型。当我们处理一个数据实例时,我们通过贝叶斯规则更新这些概率。

P(M,i) is the prior probability ascribed to model i
P(D|i) is the probability of the data, given model i
we update the P(M|i) via
S[i] = P(M,i) * P(D|i)  
T = Sum{ 1<=i<=N | S[i]}
P(M|i) = S[i]/T

当我们得到一连串的数据 使得其中一个或多个模型非常不可能时,就会出现问题,即P(D)

© www.soinside.com 2019 - 2024. All rights reserved.