回答:
正確なソリューション
回の投げの組み合わせの数は、もちろんです。
これらの計算は、1つのダイの確率生成関数を使用して最も簡単に行われます。
(実際には、これはpgfの倍です。最後にの係数を処理します。)
ロールのpgf はです。これをかなり直接計算することができます-それは閉じた形ではありませんが、有用なものです-二項定理を使用して:
サイコロでに等しい合計を取得する方法の数は、この製品のの係数であり、次のように分離できます。
合計は、6 k + j = m − nであるすべての非負のおよび渡ります。したがって、有限であり、約(m − n )/ 6項しかありません。例えば、合計に対する多数の方法M = 14でN = 3であるため、わずか2つの項の和であるスロー11 = 14 - 3が唯一のように書くことができる6 ⋅ 0 + 11と6 ⋅ 1 5:
(You can also be clever and note that the answer will be the same for by the symmetry 1 <--> 6, 2 <--> 5, and 3 <--> 4 and there's only one way to expand as ; namely, with and , giving
The probability therefore equals = , about 14%.
By the time this gets painful, the Central Limit Theorem provides good approximations (at least to the central terms where is between and : on a relative basis, the approximations it affords for the tail values get worse and worse as grows large).
I see that this formula is given in the Wikipedia article Srikant references but no justification is supplied nor are examples given. If perchance this approach looks too abstract, fire up your favorite computer algebra system and ask it to expand the power of : you can read the whole set of values right off. E.g., a Mathematica one-liner is
With[{n=3}, CoefficientList[Expand[(x + x^2 + x^3 + x^4 + x^5 + x^6)^n], x]]
R
code to compute these things, see stats.stackexchange.com/a/116913 for a fully implemented system. As another example, the Mathematica code is Clear[x, d]; d[n_, x_] := Sum[x^i, {i, 1, n}]; d[6, x] d[4, x]^3 // Expand
Yet another way to quickly compute the probability distribution of a dice roll would be to use a specialized calculator designed just for that purpose.
Torben Mogensen, a CS professor at DIKU has an excellent dice roller called Troll.
The Troll dice roller and probability calculator prints out the probability distribution (pmf, histogram, and optionally cdf or ccdf), mean, spread, and mean deviation for a variety of complicated dice roll mechanisms. Here are a few examples that show off Troll's dice roll language:
Roll 3 6-sided dice and sum them: sum 3d6
.
Roll 4 6-sided dice, keep the highest 3 and sum them: sum largest 3 4d6
.
Roll an "exploding" 6-sided die (i.e., any time a "6" comes up, add 6 to your total and roll again): sum (accumulate y:=d6 while y=6)
.
Troll's SML source code is available, if you want to see how its implemented.
Professor Morgensen also has a 29-page paper, "Dice Rolling Mechanisms in RPGs," in which he discusses many of the dice rolling mechanisms implemented by Troll and some of the mathematics behind them.
A similar piece of free, open-source software is Dicelab, which works on both Linux and Windows.
Let the first die be red and the second be black. Then there are 36 possible results:
Each of these 36 () results are equally likely.
When you sum the numbers on the faces (total in ), several of the (red,black) results end up with the same total -- you can see this with the table in your question.
So for example there's only one way to get a total of (i.e. only the event ()), but there's two ways to get (i.e. the elementary events () and ()). So a total of is twice as likely to come up as . Similarly there's three ways of getting , four ways of getting and so on.
Now since you have 36 possible (red,black) results, the total number of ways of getting all the different totals is also 36, so you should divide by 36 at the end. Your total probability will be 1, as it should be.
There's a very neat way of computing the combinations or probabilities in a spreadsheet (such as excel) that computes the convolutions directly.
I'll do it in terms of probabilities and illustrate it for six sided dice but you can do it for dice with any number of sides (including adding different ones).
(btw it's also easy in something like R or matlab that will do convolutions)
Start with a clean sheet, in a few columns, and move down a bunch of rows from the top (more than 6).
put the value 1 in a cell. That's the probabilities associated with 0 dice. put a 0 to its left; that's the value column - continue down from there with 1,2,3 down as far as you need.
move one column to the right and down a row from the '1'. enter the formula "=sum(" then left-arrow up-arrow (to highlight the cell with 1 in it), hit ":" (to start entering a range) and then up-arrow 5 times, followed by ")/6" and press Enter - so you end up with a formula like =sum(c4:c9)/6
(where here C9
is the cell with the 1 in it).
Then copy the formula and paste it to the 5 cells below it. They should each contain 0.16667 (ish).
Don't type anything into the empty cells these formulas refer to!
move down 1 and to the right 1 from the top of that column of values and paste ...
... a total of another 11 values. These will be the probabilities for two dice.
It doesn't matter if you paste a few too many, you'll just get zeroes.
repeat step 3 for the next column for three dice, and again for four, five, etc dice.
We see here that the probability of rolling on 4d6 is 0.096451 (if you multiply by you'll be able to write it as an exact fraction).
If you're adept with Excel - things like copying a formula from a cell and pasting into many cells in a column, you can generate all tables up to say 10d6 in about a minute or so (possibly faster if you've done it a few times).
If you want combination counts instead of probabilities, don't divide by 6.
If you want dice with different numbers of faces, you can sum (rather than 6) cells and then divide by . You can mix dice across columns (e.g. do a column for d6 and one for d8 to get the probability function for d6+d8):
Approximate Solution
I explained the exact solution earlier (see below). I will now offer an approximate solution which may suit your needs better.
Let:
be the outcome of a roll of a faced dice where .
be the total of all dice.
be the sample average.
By definition, we have:
In other words,
The idea now is to visualize the process of observing as the outcome of throwing the same dice times instead of as outcome of throwing dice. Thus, we can invoke the central limit theorem (ignoring technicalities associated with going from discrete distribution to continuous), we have as :
where,
is the mean of the roll of a single dice and
is the associated variance.
The above is obviously an approximation as the underlying distribution has discrete support.
But,
.
Thus, we have:
.
Exact Solution
Wikipedia has a brief explanation as how to calculate the required probabilities. I will elaborate a bit more as to why the explanation there makes sense. To the extent possible I have used similar notation to the Wikipedia article.
Suppose that you have dice each with faces and you want to compute the probability that a single roll of all dice the total adds up to . The approach is as follows:
Define:
: Probability that you get a total of on a single roll of dices with faces.
By definition, we have:
The above states that if you just have one dice with faces the probability of obtaining a total between 1 and s is the familiar .
Consider the situation when you roll two dice: You can obtain a sum of as follows: The first roll is between 1 to and the corresponding roll for the second one is between to . Thus, we have:
Now consider a roll of three dice: You can get a sum of if you roll a 1 to on the first dice and the sum on the remaining two dice is between to . Thus,
Continuing the above logic, we get the recursion equation:
See the Wikipedia link for more details.
特性関数を使用すると、ランダム変数の合計と差を含む計算が非常に簡単になります。Mathematicaには、分布を特徴的な関数に変換する組み込み関数を含む、統計分布を扱う多くの関数があります。
2つの具体的な例でこれを説明したいと思います。(1)異なる数のサイドを持つサイコロのコレクションの結果を決定したいとします。例えば、2つの6面ダイスと1つの8面ダイス、2d6 + d8)?または、(2)2つのサイコロの差を見つけたいと仮定した場合(たとえば、d6-d6)?
An easy way to do this would be to use the characteristic functions of the underlying discrete uniform distributions. If a random variable has a probability mass function , then its characteristic function is just the discrete Fourier Transform of , i.e., . A theorem tells us:
If the independent random variables and have corresponding probability mass functions and , then the pmf of the sum of these RVs is the convolution of their pmfs .
We can use the convolution property of Fourier Transforms to restate this more simply in terms of characteristic functions:
The characteristic function of the sum of independent random variables and equals the product of their characteristic functions .
This Mathematica function will make the characteristic function for an s-sided die:
MakeCf[s_] := Module[{Cf}, Cf := CharacteristicFunction[DiscreteUniformDistribution[{1, s}], t]; Cf]
The pmf of a distribution can be recovered from its characteristic function, because Fourier Transforms are invertible. Here is the Mathematica code to do it:
RecoverPmf[Cf_] := Module[{F}, F[y_] := SeriesCoefficient[Cf /. t -> -I*Log[x], {x, 0, y}]; F]
Continuing our example, let F be the pmf that results from 2d6+d8.
F := RecoverPmf[MakeCf[6]^2 MakeCf[8]]
There are outcomes. The domain of support of F is . Three is the min because you're rolling three dice. And twenty is the max because . If you want to see the image of F, compute
In:= F /@ Range[3, 20] Out= {1/288, 1/96, 1/48, 5/144, 5/96, 7/96, 13/144, 5/48, 1/9, 1/9, \ 5/48, 13/144, 7/96, 5/96, 5/144, 1/48, 1/96, 1/288}
If you want to know the number of outcomes that sum to 10, compute
In:= 6^2 8 F[10] Out= 30
If the independent random variables and have corresponding probability mass functions and , then the pmf of the difference of these RVs is the cross-correlation of their pmfs .
We can use the cross-correlation property of Fourier Transforms to restate this more simply in terms of characteristic functions:
The characteristic function of the difference of two independent random variables equals the product of the characteristic function and (N.B. the negative sign in front of the variable t in the second characteristic function).
So, using Mathematica to find the pmf G of d6-d6:
G := RecoverPmf[MakeCf[6] (MakeCf[6] /. t -> -t)]
There are outcomes. The domain of support of G is . -5 is the min because . And 5 is the max because . If you want to see the image of G, compute
In:= G /@ Range[-5, 5] Out= {1/36, 1/18, 1/12, 1/9, 5/36, 1/6, 5/36, 1/9, 1/12, 1/18, 1/36}
畳み込みを使用して手動で2つのサイコロの合計の確率分布を計算する別の方法を次に示します。
例を単純にするために、ランダム変数がXを呼び出す3面ダイス(d3)とランダム変数が2面ダイス(d2)の合計の確率分布を計算します。 Yに電話
テーブルを作成します。一番上の行に、Xの確率分布(公正なd3のローリングの結果)を記述します。左の列の下に、Yの確率分布(公正なd2のローリングの結果)を書きます。
確率の一番上の行と確率の左の列の外積を作成します。たとえば、右下のセルは、添付の図に示すように、Pr [X = 3] = 1/3倍のPr [Y = 2] = 1/2の積になります。単純化した例では、すべてのセルが1/6に等しくなります。
次に、添付図に示すように、外積マトリックスの斜線に沿って合計します。各斜線は、同じ色を付けた1つ以上のセルを通過します。上の線は1つの青いセルを通過し、次の線は2つの赤いセルを通過します。
斜線に沿った合計は、結果の分布の確率を表します。たとえば、赤血球の合計は、2つのサイコロの合計が3になる確率に等しくなります。これらの確率は、添付の図の右側に示されています。
この手法は、有限のサポートを持つ任意の2つの離散分布で使用できます。そして、繰り返し適用することができます。たとえば、3つの6面ダイス(3d6)の分布を知りたい場合は、最初に2d6 = d6 + d6を計算できます。その後、3d6 = d6 + 2d6。
Jと呼ばれる無料の(ただし、クローズドライセンス)プログラミング言語があります。APLにルーツを持つ配列ベースの言語。マトリックス内の斜線に沿って外積と合計を実行する組み込み演算子があり、実装するのが非常に簡単な手法を示しています。
次のJコードでは、2つの動詞を定義しています。最初に、動詞d
はs側のダイのpmfを表す配列を作成します。たとえばd 6
、6面ダイスのpmfです。次に、動詞conv
は2つの配列の外積を見つけ、斜線に沿って合計します。したがってconv~ d 6
、2d6のpmfを出力します。
d =:$% conv =:+ //。@(* /) |:(2 + i.11),: conv〜d 6 2 0.0277778 3 0.0555556 4 0.0833333 5 0.111111 6 0.138889 7 0.166667 8 0.138889 9 0.111111 10 0.0833333 11 0.0555556 12 0.0277778
ご覧のとおり、Jは不可解ですが、簡潔です。
これは実際には驚くほど複雑な質問です。幸いなことに、ここで非常によく説明されている正確な解決策があります。
http://mathworld.wolfram.com/Dice.html
探している確率は、式(10)で与えられます:「n個のsサイコロでpポイント(pのロール)を得る確率」。
あなたの場合:p =観測されたスコア(すべてのサイコロの合計)、n =サイコロの数、s = 6(6面サイコロ)。これにより、次の確率質量関数が得られます。
ユーザー名が大好き!よくやった :)
あなたが数えるべき結果はサイコロであり、すべて あなたのテーブルに示されているように。
例えば、 時の合計 、そして 時の合計 、そして 時の合計 、 等々。
これは、再帰的な式で解決できます。その場合、ロールの確率は サイコロは、ロールによって計算されます サイコロ。
合計のkの最初の制限は、6つの先行する数値です。たとえば、3つのサイコロで13をロールしたい場合、最初の2つのサイコロが7から12の間でロールした場合、これを実行できます。
合計のkの2番目の制限は、n-1個のサイコロで振ることのできる制限です。
結果:
1 1 1 1 1 1
1 2 3 4 5 6 5 4 3 2 1
1 3 6 10 15 21 25 27 27 25 21 15 10 6 3 1
1 4 10 20 35 56 80 104 125 140 146 140 125 104 80 56 35 20 10 4 1
1 5 15 35 70 126 205 305 420 540 651 735 780 780 735 651 540 420 305 205 126 70 35 15 5 1
編集:上記の答えは、C.Rossによって質問に統合された別の質問からの回答でした
以下のコードは、その回答(5ダイスを要求する質問に対する)の計算がRでどのように実行されたかを示しています。これらは、グレンBの回答でExcelで実行された合計に似ています。
# recursive formula
nextdice <- function(n,a,l) {
x = 0
for (i in 1:6) {
if ((l-i >= n-1) & (l-i<=6*(n-1))) {
x = x+a[l-i-(n-2)]
}
}
return(x)
}
# generating combinations for rolling with up to 5 dices
a_1 <- rep(1,6)
a_2 <- sapply(2:12,FUN = function(x) {nextdice(2,a_1,x)})
a_3 <- sapply(3:18,FUN = function(x) {nextdice(3,a_2,x)})
a_4 <- sapply(4:24,FUN = function(x) {nextdice(4,a_3,x)})
a_5 <- sapply(5:30,FUN = function(x) {nextdice(5,a_4,x)})
1つのアプローチは、確率 はの係数です 生成関数の拡張
だから、6つのサイコロとの目標を持つ例えば、 見つけるだろう 。そのリンク(math.stackexchangeの質問へ)は他のアプローチも提供します