0

如果有这样的数字系列:11.5、6.7、3.2 和 5.11

如何将这些数字转换为概率,以使结果概率之和为 1?

谢谢你。


如果数列还包括负数:-1.2、-100.34、3.67 和 2.1 怎么办?

是的,它们是与实例的 4 个可能类相关联的权重。


好的。这是我的解决方案。如果有任何改进,请随时提出改进建议。

1)通过方法将数字范围移动到1到任何n(我选择100)之间。

2)使用答案中列出的解决方案。

在步骤 1) 中选择下限为 1 的原因是为了在应用范围转换公式后不丢失最小值。

解决的例子:

Say there 2 instances that can take on 2 possible class values with weights as shown below.
Instance1: -11.0  -2.0
Instance2: 4.0    52.0

old_max = 52.0, old_min = -11.0, new_max = 100, and new_min = 1

After applying step1), the weights are now in range 1 to 100.
Instance1: 1       15.1
Instance2: 24.5    100    

On applying step2), the following probabilities are obtained.
Instance1: 0.0708   0.937
Instance2: 0.19     0.803
4

2 回答 2

2

您可以将每个数字除以总和:

double arr[] = {11.5, 6.7, 3.2, 5.11};
double total = 11.5 + 6.7 + 3.2 + 5.11;
for (int i = 0; i < arr.length; i++) {
    System.out.println(arr[i] / total);
}

这是有效的,因为总和除以总和为 1。

于 2013-07-29T15:46:30.520 回答
2

加权总和?

x1= 11.5, x2 = 6.7, x3 = 3.2, x4= 5.11
sum = x1+x2+x3+x4
p(x1) = x1/sum
p(x4) = x4/sum
....
p(total) = p(x1) + p(x2) + p(x3) + p(x4) = 1
于 2013-07-29T15:47:08.383 回答