如何获得三个变量的确切机会?

How to get exact chance of three variables?

我正在努力计算用户获得物品的估计机会。他有 15 次尝试(可能会有所不同),有机会进入物品组,然后有机会获得确切的物品。我可以看到两种方法,但 none 是完美的。请看:

    int userTries = 15;//Variable holding number of how many tries user has to get an item
    double groupChance = 17;//Chance for user to get any item from the group
    double itemChance = 80;//Chance for user to get specific item from the group

    double simpleChance = groupChance * itemChance * userTries / 100.0;

    int correctionTries = 10000;
    int totalPassed = 0;
    for (int i = 0;i < correctionTries;i++)
    {
        for (int x = 0;x < userTries;x++)
        {
            //Rnd.chance is checking if input chance was rolled, if chance is 17 then this method will return true in 17 tries out of 100
            if (Rnd.chance(groupChance))
                if (Rnd.chance(itemChance))
                {
                    totalPassed++;
                    break;
                }
        }
    }
    double iterationChance = (double) totalPassed / (double) correctionTries * 100.0;
    System.out.println("simple=" + simpleChance + " iteration=" + iterationChance);

当 groupChance 和 itemChance 较低(如 1 和 1)时,simpleChance 会给出非常好的结果,但当机会较高时(如 17 和 80),它们与迭代结果相差很大。迭代解决方案的问题是,当我增加其中一次机会时,结果实际上会因为计算机会中的运气不好而降低。我可以增加 correctionTries 来解决这个问题,但是再次计算相同的值时机会会有所不同,这也会对性能产生重大影响。

你知道有什么方法可以计算再次计算后保持不变的低性能影响和良好估计的机会吗?

假设 groupChanceitemChance 是进入特定组并获得 的概率(百分比) 组中的特定项目..

如果是,那么得到这个具体物品的概率是groupChance/100 * itemChance/100 = 0.17*0.8 = 0.136 = 13.6%

也不清楚 simpleChance 应该是什么 => 在 15 次尝试后至少获得一次 特定项目? 15 次尝试后正好一次??连续获得 15 次?

  • 如果你想连续获得15次,那么机会是(groupChance/100 * itemChance/100 ) ^ userTries = 0.000000000000101
  • 如果你想在尝试15次后至少得到一次,那么机会是1 - ( 1 - groupChance/100 * itemChance/100 ) ^ userTries = 0.88839