Deriving the probability of winning a dice game with two different sets of dice?

76 Views Asked by At

Purely out of curiosity, I wanted to determine the probability of winning a dice game when each set of dice is not the same. For example, Player 1 has a dice set of $[d_{20}, d_{4}]$, and Player 2 has $[d_6, d_6, d_6, d_6]$. I can get the average outcome of both sets (13 and 14, respectively), but I can't seem to figure out a way to get the exact probability of one player winning.

When I simulate this scenario in a program, the average win rate is approximately 52.5% in favor of Player 2. I was wondering if there is a way to figure out the average win rate for this scenario and if I could generalize this for any two sets of dice.

2

There are 2 best solutions below

1
On BEST ANSWER

If a player throws $\ d\ $ dice, then his score $\ S\ $ is the sum of $\ d\ $ independent random variables: $$ S=\sum_{i=1}^dT_i\ , $$ where $\ T_i\ $ is the number appearing on the uppermost face of the $\ i^\text{th}\ $ die. If player $1$'s score is $\ S_1\ $, player $2$'s is $\ S_2\ $, and the difference $\ Z=$$\,S_2-S_1\ $ has probability mass function $\ \zeta:\mathbb{Z}\rightarrow[0,1]\ $ then the probability that player $2$ wins is just \begin{align} \mathbb{P}(Z>0)&=\sum_{i=1}^\infty\mathbb{P}(Z=i)\\&=\sum_{i=1}^\infty\zeta(i)\ . \end{align} Although the above sums have an upper limit of $\ \infty\ $, in fact they're only finite, because $\ \zeta\ $ has only a finite number of non-zero values.

Now the probability mass function $\ \sigma\ $ of the sum $\ X_1+X_2\ $ of two independent random variables $\ X_1,X_2\ $, with probability mass functions $\ \chi_1, \chi_2\ $ respectively, is just the convolution of $\ \chi_1\ $ and $\ \chi_2\ $: \begin{align} \sigma(j)&=\mathbb{P}(X_1+X_2=j)\\ &=\sum_{i=-\infty}^\infty\mathbb{P}(X_1=i,X_2=j-i)\\ &=\sum_{i=-\infty}^\infty\mathbb{P}(X_1=i)\,\mathbb{P}(X_2=j-i)\\ &=\sum_{i=-\infty}^\infty\chi_1(i)\,\chi_2(j-i)\\ &=(\chi_1*\chi_2)(j)\ . \end{align} The operation of convolution is associative and commutative, so the individual convolution operations in a series of convolutions $\ \chi_1*$$\,\chi_2*$$\,\dots*$$\,\chi_d\ $ can be carried out in any order.

Thus, the probability mass functions of $\ S_1\ $ and $\ S_2\ $ are just the convolutions of the probability mass functions of the summands of which they are the sum. When an $\ n$-faced fair die labelled with the numbers $\ 1,2,\dots,n\ $ is thrown, the probability mass function $\ \mu_n\ $ of the number appearing on its uppermost face is given by $$ \mu_n(i)=\cases{\frac{1}{n}&if $\ 1\le i\le n$\\ 0&if $\ i\le0\text{ or }\ n+1\le i\ $.} $$ If player $1$ throws $\ d_1\ $ dice with $\ n_1,n_2,\dots,n_{d_1}\ $ faces and player $2$ throws $\ d_2\ $ dice with $\ m_1,m_2,\dots,m_{d_2}\ $ faces, then the probability mass functions of $\ S_1\ $ and $\ S_2\ $ will be \begin{align} \sigma_1&=\mu_{n_1}*\mu_{n_2}*\dots*\mu_{n_{d_1}}\ \text{ and}\\ \sigma_2&=\mu_{m_1}*\mu_{m_2}*\dots*\mu_{m_{d_2}} \end{align} respectively. The probability mass function $\ \zeta\ $ of $\ Z=S_2-S_1\ $ will be given by $$ \zeta=\sigma_2*\sigma_1^-\ .\, $$ where $\ \sigma_1^-(i)=\sigma_1(-i)\ $ for all $\ i\in\mathbb{Z}\ $. For the specific problem posed in the question we'll have $\ \sigma_1=\mu_{20}*\mu_4\ $ and $\ \sigma_2=\mu_6*\mu_6*\mu_6*\mu_6\ $.

Thus, in principle there's nothing really very complicated in calculating the probability of each of the player's winning the game or the probability of a tie. The messiness mentioned in user2661923's answer is really just that of calculating the necessary convolutions by hand. It's not difficult to write a computer program or script to do the job.

The R statistical package incorporates several procedures for computing convolutions. Unfortunately, none that I found seems capable of directly calculating the convolution of two probability mass functions that assign positive probabilities to negative integers. With a little bit of fiddling, it would be possible to adapt gconv to do this, but since I'm not all that familiar with the R scripting language, I guessed I would probably find it easier to write a Magma script to do all the calculations. The script below calculates the probabilities of each of the two player's winning the game described in the question. If you copy and paste it into the online Magma calculator and press submit, it produces the following output:

    probability player 2 wins = 9071/17280 , = approximately 0.5249421296
    probability of tie = 2581/51840 = approximately 0.04978780864
    probability player 1 wins = 11023/25920 = approximately 0.4252700617

in good agreement with the result you obtained by simulation.

You can play around with what happens when the players are given different sets of dice by modifying the values of the variables p1dice and p2dice in the first two lines.

   p1dice:=[20,4];
   p2dice:=[6,6,6,6];

   setupdie:=function(n)
      dn:=ZeroMatrix(Rationals(),1,2+n);
      dn[1,1]:=1;
      dn[1,2]:=n;
      for i in [1..n] do
         dn[1,i+2]:=1/n;
      end for;
      return dn;
    end function;

    convolve:= function(a,b)
       minv:=a[1,1]+b[1,1];
       maxv:=a[1,2]+b[1,2];
       n:=Integers()!(maxv+1-minv);
       result:=ZeroMatrix(Rationals(),1,2+n);
       result[1,1]:=minv;
       result[1,2]:=maxv;
       for i in [1..(a[1,2]+1-a[1,1])] do
           for j in [1..(b[1,2]+1-b[1,1])] do
              result[1,i+j+1]:=result[1,i+j+1]+a[1,i+2]*b[1,j+2];
           end for;
       end for;
       return result;
    end function;

    function negate(a)
       minv:=-a[1,2];
       maxv:=-a[1,1];
       n:=Integers()!(maxv+1-minv);
       result:=ZeroMatrix(Rationals(),1,2+n);
       result[1,1]:=minv;
       result[1,2]:=maxv;
       for i in [1..n] do
           result[1,i+2]:=a[1,n+3-i];
       end for;
       return result;
    end function;

    getdist:=function(dicelist)
       dist:=setupdie(dicelist[1]);
       for i in [2..#dicelist] do
         dist:=convolve(dist,setupdie(dicelist[i]));
       end for;
       return dist;
    end function;
    p1d:=getdist(p1dice);
    p2d:=getdist(p2dice);
    p1d:=negate(p1d);
    dfr:=convolve(p1d,p2d);
    lb:=Integers()!(2-dfr[1,1]);
    ub:=Integers()!(dfr[1,2]+1-dfr[1,1]);
    tot:=0;
    for i in [lb..ub] do
       tot:=tot+dfr[1,i+2];
    end for;

    print "probability player 2 wins =", tot, ", = approximately", RealField(10)!tot;
    print "probability of tie =", dfr[1,lb+1], "= approximately", RealField(10)!dfr[1,lb+1];
    print "probability player 1 wins =", 1-tot-dfr[1,lb+1], "= approximately", RealField(10)!(1-tot-dfr[1,lb+1]);
2
On

The math is do-able, but messy. You can set up a closed form for the computations, and then write a computer program do the heavy lifting. So, you don't need to do a simulation as such.

I am assuming that die $dn$ refers to an $n$-sided die, whose (equally likely) sides are $\{1,2,\cdots,n\}.$

This means that the sum of the $[d6,d6,d6,d6]$ dice will be in the range of $\{4,5,6,\cdots,24\}.$

Similarly, the sum of the $[d20,d4]$ dice will be in the range of $\{2,3,\cdots,24\}.$


For $~n \in \{4,5,6, \cdots, 24\}, ~$ let $f(n)$ denote the probability that $[d6,d6,d6,d6]$ sum to $n$.

This can be routinely calculated by a computer program. Simply have each of the dice loop through the values of $1$ through $6$, so that your program is examining $1296$ cases. If, in the $1296$ cases, the sum $n$ occurs $r$ times, then $~\displaystyle f(n) = \frac{r}{1296}.$

For $~n \in \{2,3,4,5,6, \cdots, 24\}, ~$ let $g(n)$ denote the probability that $[d20,d4]$ sum to $n$.

This can also be routinely calculated by a computer program. Simply have one die loop through the values $1$ through $20$, while the other die loops through the values $1$ through $4$, so that your program is examining $80$ cases. If, in the $80$ cases, the sum $n$ occurs $r$ times, then $~\displaystyle g(n) = \frac{r}{80}.$

For $~n \in \{2,3,4,5,6, \cdots, 24\}, ~$ let $h(n)$ denote the probability that $[d20,d4]$ sum to strictly less than $n$.

For $~n \in \{2,3,4,5,6, \cdots, 24\}, ~$ let $j(n)$ denote the probability that $[d20,d4]$ sum to strictly greater than $n$.

This means that

  • $h(2) = 0.$
  • $h(n) = \sum_{k=2}^{n-1} g(k) ~: 3 \leq n \leq 24.$
  • $j(24) = 0.$
  • $j(n) = \sum_{k=n+1}^{24} g(k) ~: 2 \leq n \leq 23.$

Then, the chance of Player 2 winning is

$$\sum_{i=4}^{24} f(i) \times h(i).$$

Then, the chance of Player 1 winning is

$$\sum_{i=4}^{24} f(i) \times j(i).$$

Then, the chance of a tie is

$$\sum_{i=4}^{24} f(i) \times g(i).$$