Je veux calculer la distribution de probabilité pour le total d'une combinaison de dés.
Je me souviens que la probabilité de est le nombre de combinaisons qui totalisent ce nombre sur le nombre total de combinaisons (en supposant que les dés ont une distribution uniforme).
Quelles sont les formules pour
- Le nombre total de combinaisons
- Le nombre de combinaisons qui totalisent un certain nombre
probability
dice
Traverser
la source
la source
Réponses:
Solutions exactes
Le nombre de combinaisons enn lancers est bien sûr de 6n .
Ces calculs sont plus faciles à faire en utilisant la fonction de génération de probabilité pour un dé,
(En fait, c'est6 fois le pgf - je m'occuperai du facteur 6 à la fin.)
Le pgf pourn rouleaux est p(x)n . Nous pouvons calculer cela assez directement - ce n'est pas un formulaire fermé mais c'est un formulaire utile - en utilisant le théorème binomial:
Le nombre de façons d'obtenir une somme égale àm sur les dés est le coefficient de xm dans ce produit, que nous pouvons isoler comme
La somme est sur tous lesk et j non négatifs pour lesquels 6 k + j = m - n ; il est donc fini et ne comporte qu'environ ( m - n ) / 6 termes. Par exemple, le nombre de façons de totaliser m = 14 en n = 3 lancers est une somme de seulement deux termes, car 11 = 14 - 3 ne peut s'écrire que 6 ⋅ 0 + 11 et 6 ⋅ 1 + 5 :
(Vous pouvez également être intelligent et noter que la réponse sera la même pourm = 7 par la symétrie 1 <--> 6, 2 <--> 5 et 3 <--> 4 et il n'y a qu'une seule façon de développer 7 - 3 comme 6k+j , à savoir, avec k=0 et j=4 , ce qui donne
La probabilité est donc égale à15/63 = 5/36 , environ 14%.
Au moment où cela devient douloureux, le théorème de la limite centrale fournit de bonnes approximations (au moins aux termes centraux oùm est compris entre 7n2−3n−−√ et7n2+ 3n−-√ : sur une base relative, les approximations qu'il fournit pour les valeurs de queue empirent de plus en plus à mesure quen grandit).
Je vois que cette formule est donnée dans l'article Wikipédia des références Srikant mais aucune justification n'est fournie ni aucun exemple donné. Si par hasard cette apparence approche trop abstraite, lancez votre système d'algèbre informatique préféré et demander d'élargir lane puissance de x + x2+ ⋯ + x6 : vous pouvez lire l'ensemble des valeurs de bon pied. Par exemple , une doublure Mathematica est
la source
R
code to compute these things, see stats.stackexchange.com/a/116913 for a fully implemented system. As another example, the Mathematica code isClear[x, d]; d[n_, x_] := Sum[x^i, {i, 1, n}]; d[6, x] d[4, x]^3 // Expand
Une autre façon de calculer rapidement la distribution de probabilité d'un lancer de dés serait d'utiliser une calculatrice spécialisée conçue spécialement à cet effet.
Torben Mogensen , professeur CS à DIKU a un excellent rouleau de dés appelé Troll .
Le rouleau de dés Troll et le calculateur de probabilité impriment la distribution de probabilité (pmf, histogramme et éventuellement cdf ou ccdf), la moyenne, l'étalement et l'écart moyen pour une variété de mécanismes compliqués de lancer de dés. Voici quelques exemples qui montrent la langue du lancer de dés de Troll:
Rouler 3 dés à 6 faces et les résumer:
sum 3d6
.Rouleau 4 dés à 6 faces, gardez le plus 3 et les résumer:
sum largest 3 4d6
.Rouler une « explosion » dé à 6 faces (c. -à- tout moment un « 6 » apparaît, ajoutez 6 à nouveau votre totale et rouleau):
sum (accumulate y:=d6 while y=6)
.Le code source SML de Troll est disponible, si vous voulez voir comment son implémenté.
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.
la source
Let the first die be red and the second be black. Then there are 36 possible results:
Each of these 36 (red,black ) results are equally likely.
When you sum the numbers on the faces (total inblue ), 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 of2 (i.e. only the event (1,1 )), but there's two ways to get 3 (i.e. the elementary events (2,1 ) and (1,2 )). So a total of 3 is twice as likely to come up as 2 . Similarly there's three ways of getting 4 , four ways of getting 5 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.
la source
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 hereC9
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 rolling12 on 4d6 is 0.096451 (if you multiply by 46 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 sumk (rather than 6) cells and then divide by k . 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):
la source
Approximate Solution
I explained the exact solution earlier (see below). I will now offer an approximate solution which may suit your needs better.
Let:
By definition, we have:
In other words,
The idea now is to visualize the process of observingXi as the outcome of throwing the same dice n times instead of as outcome of throwing n dice. Thus, we can invoke the central limit theorem (ignoring technicalities associated with going from discrete distribution to continuous), we have as n→∞ :
where,
The above is obviously an approximation as the underlying distributionXi 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 haven dice each with s faces and you want to compute the probability that a single roll of all n dice the total adds up to k . The approach is as follows:
Define:
By definition, we have:
The above states that if you just have one dice withs faces the probability of obtaining a total k between 1 and s is the familiar 1s .
Consider the situation when you roll two dice: You can obtain a sum ofk as follows: The first roll is between 1 to k−1 and the corresponding roll for the second one is between k−1 to 1 . Thus, we have:
Now consider a roll of three dice: You can get a sum ofk if you roll a 1 to k−2 on the first dice and the sum on the remaining two dice is between k−1 to 2 . Thus,
Continuing the above logic, we get the recursion equation:
See the Wikipedia link for more details.
la source
Les fonctions caractéristiques peuvent rendre les calculs impliquant les sommes et les différences de variables aléatoires très faciles. Mathematica possède de nombreuses fonctions pour travailler avec des distributions statistiques, y compris un intégré pour transformer une distribution en sa fonction caractéristique.
Je voudrais illustrer cela avec deux exemples concrets: (1) Supposons que vous vouliez déterminer les résultats du lancement d'une collection de dés avec différents nombres de côtés, par exemple, lancez deux dés à six faces plus un dé à huit faces (c.-à-d. , 2d6 + d8 )? Ou (2) supposons que vous vouliez trouver la différence de deux lancers de dés (par exemple, d6-d6 )?
An easy way to do this would be to use the characteristic functions of the underlying discrete uniform distributions. If a random variableX has a probability mass function f , then its characteristic function φX(t) is just the discrete Fourier Transform of f , i.e., φX(t)=F{f}(t)=E[eitX] . A theorem tells us:
If the independent random variablesX and Y have corresponding probability mass functions f and g , then the pmf h of the sum X+Y of these RVs is the convolution of their pmfs h(n)=(f∗g)(n)=∑∞m=−∞f(m)g(n−m) .
We can use the convolution property of Fourier Transforms to restate this more simply in terms of characteristic functions:
The characteristic functionφX+Y(t) of the sum of independent random variables X and Y equals the product of their characteristic functions φX(t)φY(t) .
This Mathematica function will make the characteristic function for an s-sided die:
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:
Continuing our example, let F be the pmf that results from 2d6+d8.
F := RecoverPmf[MakeCf[6]^2 MakeCf[8]]
There are62⋅8=288 outcomes. The domain of support of F is S={3,…,20} . Three is the min because you're rolling three dice. And twenty is the max because 20=2⋅6+8 . If you want to see the image of F, compute
If you want to know the number of outcomes that sum to 10, compute
If the independent random variablesX and Y have corresponding probability mass functions f and g , then the pmf h of the difference X−Y of these RVs is the cross-correlation of their pmfs h(n)=(f⋆g)(n)=∑∞m=−∞f(m)g(n+m) .
We can use the cross-correlation property of Fourier Transforms to restate this more simply in terms of characteristic functions:
The characteristic functionφX−Y(t) of the difference of two independent random variables X,Y equals the product of the characteristic function φX(t) and φY(−t) (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 are62=36 outcomes. The domain of support of G is S={−5,…,5} . -5 is the min because −5=1−6 . And 5 is the max because 6−1=5 . If you want to see the image of G, compute
la source
Here's another way to calculate the probability distribution of the sum of two dice by hand using convolutions.
To keep the example really simple, we're going to calculate the probability distribution of the sum of a three-sided die (d3) whose random variable we will call X and a two-sided die (d2) whose random variable we'll call Y.
You're going to make a table. Across the top row, write the probability distribution of X (outcomes of rolling a fair d3). Down the left column, write the probability distribution of Y (outcomes of rolling a fair d2).
You're going to construct the outer product of the top row of probabilities with the left column of probabilities. For example, the lower-right cell will be the product of Pr[X=3]=1/3 times Pr[Y=2]=1/2 as shown in the accompanying figure. In our simplistic example, all the cells equal 1/6.
Next, you're going to sum along the oblique lines of the outer-product matrix as shown in the accompanying diagram. Each oblique line passes through one-or-more cells which I've colored the same: The top line passes through one blue cell, the next line passes through two red cells, and so on.
Each of the sums along the obliques represents a probability in the resulting distribution. For example, the sum of the red cells equals the probability of the two dice summing to 3. These probabilities are shown down the right side of the accompanying diagram.
This technique can be used with any two discrete distributions with finite support. And you can apply it iteratively. For example, if you want to know the distribution of three six-sided dice (3d6), you can first calculate 2d6=d6+d6; then 3d6=d6+2d6.
There is a free (but closed license) programming language called J. Its an array-based language with its roots in APL. It has builtin operators to perform outer products and sums along the obliques in matrices, making the technique I illustrated quite simple to implement.
In the following J code, I define two verbs. First the verb
d
constructs an array representing the pmf of an s-sided die. For example,d 6
is the pmf of a 6-sided die. Second, the verbconv
finds the outer product of two arrays and sums along the oblique lines. Soconv~ d 6
prints out the pmf of 2d6:As you can see, J is cryptic, but terse.
la source
This is actually a suprisingly complicated question. Luckily for you, there exist an exact solution which is very well explained here:
http://mathworld.wolfram.com/Dice.html
The probability you are looking for is given by equation (10): "The probability of obtaining p points (a roll of p) on n s-sided dice".
In your case: p = the observed score (sum of all dice), n = the number of dice, s = 6 (6-sided dice). This gives you the following probability mass function:
la source
Love the username! Well done :)
The outcomes you should count are the dice rolls, all6×6=36 of them as shown in your table.
For example,136 of the time the sum is 2 , and 236 of the time the sum is 3 , and 436 of the time the sum is 4 , and so on.
la source
Vous pouvez résoudre ce problème avec une formule récursive. Dans ce cas, les probabilités des rouleaux avecn les dés sont calculés par les jets avec n - 1 dé.
La première limite pour k dans la somme est les six nombres précédents. Par exemple, si vous voulez lancer 13 avec 3 dés, vous pouvez le faire si vos deux premiers dés lancent entre 7 et 12.
La deuxième limite pour k dans la sommation est la limite de ce que vous pouvez lancer avec n-1 dés
Le résultat:
modifier: La réponse ci-dessus était une réponse d' une autre question qui a été fusionnée dans la question par C.Ross
Le code ci-dessous montre comment les calculs pour cette réponse (à la question demandant 5 dés) ont été effectués dans R. Ils sont similaires aux sommations effectuées dans Excel dans la réponse de Glen B.
la source
Une approche consiste à dire que la probabilitéXn= k est le coefficient de Xk dans l'expansion de la fonction génératrice
Ainsi, par exemple, avec six dés et une cible dek = 22 , tu trouveras P( X6= 22 ) = 1066 . Ce lien (vers une question math.stackexchange) donne également d'autres approches
la source