gpt4 book ai didi

javascript - 如何根据输入值及其概率计算最有可能的输出?

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:39:30 25 4
gpt4 key购买 nike

我有一组值及其适当的真实概率。我需要根据所有可用的输入值找到最可能的值。注意:概率是主观的并且可能会发生冲突 - 但它们代表最终输出的真实性。

例如这样的数据集。

data = [
{value: 1, probability: 1},
{value: 1, probability: 0.5}
];
// i would expect to output 1, because all input agree on the value and 1 is certain in its value.
data = [
{value: 1, probability: 1},
{value: 0.5, probability: 1}
];
// Id expect the value to be half way between 1 and 0.5. Both values are equally likely - so final output is in between the 2.
data = [
{value: 1, probability: 1},
{value: 0.5, probability: 0.1}
];
// Id expect the value to be almost 1 but not quite.
data = [
{value: 1, probability: 1},
{value: 1, probability: 0.1},
{value: 0.1, probability: 1},
{value: 0, probability: 0.5},
{value: 0, probability: 0.9},
... thousands of more values here ...
quickly gets complicated and cpu intensive
];

最佳答案

您似乎在寻找 weighted average .将每个值乘以其概率,计算乘积之和,然后除以概率之和。

First example:  (1.0*1.0 + 1.0*0.5) / (1.0+0.5) = 1.5/1.5  = 1.00 
Second example: (1.0*1.0 + 0.5*1.0) / (1.0+1.0) = 1.5/2.0 = 0.75
Third example: (1.0*1.0 + 0.5*0.1) / (1.0+0.1) = 1.05/1.1 = 0.95

关于javascript - 如何根据输入值及其概率计算最有可能的输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53242942/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com