\begingroup

我有 10 个骰子。将它们全部掷在一起,计算总和为 31 的概率:

allpos = Tuples[{Range[6], Range[6], Range[6], Range[6], Range[6], Range[6], Range[6], Range[6], Range[6], Range[6]}];
select = Cases[allpos, a_ /; Total[a] == 31];
prob = Length[select]/Length[allpos]

得出的结果为:1696805/30233088 ~ 5.61%

现在有两个问题:

1)

我们如何从集合中选出所有可能不同的 10 个数字?

例如:{1, 1, 1, 1, 1, 1, 4, 6, 6, 6} 和 {6, 6, 6, 4, 1, 1, 1, 1, 1, 1} 是相同的(同一集合在任何位置的任何其他排列也相同。我喜欢抑制这些,只说:六个 1 和一个 4 和三个 6 只是一组解决方案,依此类推…… 鉴于此,这个有多少组解决方案?

换句话说:使用 1->6 范围内的 10 个数字,有多少组不同的变化可以得出总和为 31?

2)

所有总和的范围将在 10 到 60 之间。有没有一种快速的方法可以一次性获得每个概率的所有概率(不通过我上面的方法)并按降序排列?

\endgroup


最佳答案
1

\begingroup

更新答案

找到概率最高的分区:

ip = Select[Max[#] < 7 &][IntegerPartitions[31, {10}]];
res = SortBy[{#, Length[Permutations[#]]} & /@ ip, -#[[2]] &];
grd = Grid[
  With[{tot = Total[res[[All, 2]]]}, {Row[#1, ","], #2/6^10} & @@@ 
    res], Frame -> All]

原始答案

您可以使用IntegerPartitions,例如:

ip = Select[Max[#] < 7 &][IntegerPartitions[31, {10}]];
Total[(Length /@ Permutations /@ ip)]/6^10

->

1696805/30233088

另外,您可以使用MultinomialDistributionTransformedDistribution来计算概率:

xa = Array[x, 6];
td = TransformedDistribution[Range[6] . xa, 
   xa \[Distributed] MultinomialDistribution[10, Table[1/6, 6]]];
Probability[z == 31, z \[Distributed] td]

-> 1696805/30233088

Grid[ip, Background -> {Automatic, {{LightBlue, White}}}]

\endgroup

8

  • 1
    \begingroup
    Total非常快!可以通过从中删除 来找到 OP 问题的第二部分Total[(Length /@ Permutations /@ ip)]/6^10
    \endgroup


    – 

  • \begingroup
    @JimB 我错过了第二部分,谢谢你的澄清
    \endgroup


    – 

  • \begingroup
    哎呀!我看到原帖者想要的是与每个唯一集合相关的概率,而不仅仅是总和为 31 的集合。或者只是个别总和。我需要学习如何阅读。
    \endgroup


    – 


  • 2
    \begingroup
    @Steve237 抱歉,我没抓住问题的重点,但正如 JimB 指出的那样,你可以从方法中判断出来。我有时间会编辑答案。
    \endgroup


    – 

  • 1
    \begingroup
    作为临时的创可贴,请尝试Transpose[{ip, (Length /@ Permutations /@ ip)/6^10}]。这仅处理总计为 31 的安排。
    \endgroup


    –