简体   繁体   English

从一系列数字产生概率

[英]generate probabilities from a series of numbers

If there's a number series as so: 11.5, 6.7, 3.2, and 5.11 如果存在这样的数字系列:11.5、6.7、3.2和5.11

How does one convert these numbers into probabilities so that the sum of the resultant probabilities is 1? 一个人如何将这些数字转换为概率,以使结果的总和为1?

Thank you. 谢谢。


What if the number series also includes negative numbers: -1.2, -100.34, 3.67, and 2.1 ? 如果数字系列还包含负数:-1.2,-100.34、3.67和2.1,该怎么办?

Yes, they are weights associated with 4 possible classes for an instance. 是的,它们是与一个实例的4个可能的类别关联的权重。


ok. 好。 Here's my solution. 这是我的解决方案。 Feel free to suggest improvements if any. 如有任何改进,请随时提出建议。

1) shift the range of numbers to be between 1 to any n(I choose 100) by method . 1)通过方法将数字范围在1到任意n(我选择100)之间。

2) use the solution listed in answers. 2)使用答案中列出的解决方案。

The reason for choosing the lower bound as 1 in step 1) is to not loose the min value after applying the range conversion formula. 在步骤1)中将下限选择为1的原因是在应用范围转换公式后不放松最小值。

Solved Example: 解决的例子:

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

You can divide each number by the sum: 您可以将每个数字除以总和:

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);
}

This works because the sum divided by the sum is 1. 这是有效的,因为总和除以1。

A weighted sum? 加权总和?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM