{"id":2826,"date":"2020-05-15T19:30:04","date_gmt":"2020-05-16T00:30:04","guid":{"rendered":"https:\/\/laurentlessard.com\/bookproofs\/?p=2826"},"modified":"2020-05-18T16:38:53","modified_gmt":"2020-05-18T21:38:53","slug":"dungeons-dragons","status":"publish","type":"post","link":"https:\/\/laurentlessard.com\/bookproofs\/dungeons-dragons\/","title":{"rendered":"Dungeons &#038; Dragons"},"content":{"rendered":"<body><p><\/p>This week\u2019s <a href=\"https:\/\/fivethirtyeight.com\/features\/can-you-find-the-best-dungeons-dragons-strategy\/\">Riddler Classic<\/a> is a probability problem about the game Dungeons &amp; Dragons. Here it goes:\n<blockquote><p>\nWhen you roll a die \u201cwith advantage,\u201d you roll the die twice and keep the higher result. Rolling \u201cwith disadvantage\u201d is similar, except you keep the lower result instead. The rules further specify that when a player rolls with both advantage and disadvantage, they cancel out, and the player rolls a single die. Yawn!<\/p>\n<p>There are two other, more mathematically interesting ways that advantage and disadvantage could be combined. First, you could have \u201cadvantage of disadvantage,\u201d meaning you roll twice with disadvantage and then keep the higher result. Or, you could have \u201cdisadvantage of advantage,\u201d meaning you roll twice with advantage and then keep the lower result. With a fair 20-sided die, which situation produces the highest expected roll: advantage of disadvantage, disadvantage of advantage or rolling a single die?<\/p>\n<p><em>Extra Credit:<\/em> Instead of maximizing your expected roll, suppose you need to roll N or better with your 20-sided die. For each value of N, is it better to use advantage of disadvantage, disadvantage of advantage or rolling a single die?\n<\/p><\/blockquote>\n<p>Here is a detailed derivation of the relevant probabilities:<br>\n<a href=\"javascript:Solution('soln_dnd','toggle_dnd')\" id=\"toggle_dnd\">[Show Solution]<\/a><\/p>\n<div id=\"soln_dnd\" style=\"display: none\">\n<p>We\u2019ll use the following notation:<br>\n\\begin{align}<br>\nf_k &amp;= \\mathbf{Prob}(X=k) &amp; &amp;\\text{(probability mass function, pmf)} \\\\<br>\nF_k &amp;= \\mathbf{Prob}(X\\leq k) &amp; &amp;\\text{(cumulative mass function, cmf)} \\\\<br>\n\\bar F_k &amp;= \\mathbf{Prob}(X\\geq k) &amp; &amp;\\text{(complementary cmf)}<br>\n\\end{align}where $X$ is the outcome of a single roll of a fair $n$-sided die. Since it\u2019s a fair die, these are:<br>\n\\[<br>\nf_k=\\frac{1}{n}, \\qquad F_k=\\frac{k}{n}, \\qquad \\bar F_k=\\frac{n-k+1}{n}.<br>\n\\]Let\u2019s tackle the more complicated cases one by one. For the other events of interest, we\u2019ll use similar notation but with superscripts \u201cA\u201d (advantage), \u201cD\u201d (disadvantage), \u201cAD\u201d (advantage of disadvantage), and \u201cDA\u201d (disadvantage of advantage). So, for example, $f^\\textrm{DA}_k$ is the pmf for rolling with disadvantage of advantage.<\/p>\n<h3>Rolling with advantage<\/h3>\n<p>Here, we roll the die twice and take the largest value. We can leverage the following property of the maximum function: $\\max(x,y) \\le k$ if and only if $x\\le k$ and $y\\le k$. If $X_1$ and $X_2$ are independent rolls of an $n$-sided die, we have:<br>\n\\begin{align}<br>\nF^{\\mathrm{A}}_k &amp;= \\mathbf{Prob}(\\max(X_1,X_2) \\le k) \\\\<br>\n&amp;= \\mathbf{Prob}(X_1\\le k,X_2\\le k) \\\\<br>\n&amp;= \\mathbf{Prob}(X_1\\le k)\\,\\mathbf{Prob}(X_2\\le k) \\\\<br>\n&amp;= F_k^2 \\\\<br>\n&amp;= \\left(\\frac{k}{n}\\right)^2<br>\n\\end{align}Finally, we can use the fact that $f^{\\mathrm{A}}_k = F^{\\mathrm{A}}_k-F^{\\mathrm{A}}_{k-1}$ to compute the pmf:<br>\n\\[<br>\nf^{\\mathrm{A}}_k = \\frac{2k-1}{n^2}<br>\n\\]<\/p>\n<h3>Rolling with disadvantage<\/h3>\n<p>Here, we use a similar approach, but with the complementary cmf instead:<br>\n\\begin{align}<br>\n\\bar F^{\\mathrm{D}}_k &amp;= \\mathbf{Prob}(\\min(X_1,X_2) \\ge k) \\\\<br>\n&amp;= \\mathbf{Prob}(X_1\\ge k,X_2\\ge k) \\\\<br>\n&amp;= \\mathbf{Prob}(X_1\\ge k)\\mathbf{Prob}(X_2\\ge k) \\\\<br>\n&amp;= \\bar F_k^2 \\\\<br>\n&amp;= \\left(\\frac{n-k+1}{n}\\right)^2<br>\n\\end{align}Finally, we can use the fact that $f^{\\mathrm{D}}_k = \\bar F^{\\mathrm{D}}_k-\\bar F^{\\mathrm{D}}_{k+1}$ to compute the pmf:<br>\n\\[<br>\nf^{\\mathrm{D}}_k = \\frac{2n-2k+1}{n^2}<br>\n\\]<\/p>\n<h3>Rolling with advantage of disadvantage<\/h3>\n<p>This case can be computed by iterating the strategies used in the previous two cases. Specifically:<br>\n\\begin{align}<br>\nF^{\\mathrm{AD}}_k &amp;= \\left( F^{\\mathrm{D}}_k \\right)^2 \\\\<br>\n&amp;= \\left( 1-\\bar F^{\\mathrm{D}}_{k+1} \\right)^2 \\\\<br>\n&amp;= \\left( 1-\\left(\\frac{n-k}{n}\\right)^2 \\right)^2 \\\\<br>\n&amp;= \\frac{k^2(2n-k)^2}{n^4}<br>\n\\end{align}As before, we can compute the pmf using $f^{\\mathrm{AD}}_k = F^{\\mathrm{AD}}_k-F^{\\mathrm{AD}}_{k-1}$:<br>\n\\[<br>\nf^{\\mathrm{AD}}_k = \\frac{(2 k-2 n-1) \\left(2 k^2-4 k n-2 k+2 n+1\\right)}{n^4}<br>\n\\]<\/p>\n<h3>Rolling with disadvantage of advantage<\/h3>\n<p>This case can also be computed by iterating the previous cases. Specifically:<br>\n\\begin{align}<br>\n\\bar F^{\\mathrm{DA}}_k &amp;= \\left( \\bar F^{\\mathrm{A}}_k \\right)^2 \\\\<br>\n&amp;= \\left( 1-F^{\\mathrm{A}}_{k-1} \\right)^2 \\\\<br>\n&amp;= \\left( 1-\\left(\\frac{k-1}{n}\\right)^2 \\right)^2 \\\\<br>\n&amp;= \\frac{(k-n-1)^2 (k+n-1)^2}{n^4}<br>\n\\end{align}As before, we can compute the pmf using $f^{\\mathrm{DA}}_k = \\bar F^{\\mathrm{DA}}_k-\\bar F^{\\mathrm{DA}}_{k+1}$:<br>\n\\[<br>\nf^{\\mathrm{DA}}_k = \\frac{(1-2 k) \\left(2 k^2-2 k-2 n^2+1\\right)}{n^4}<br>\n\\]<\/p>\n<h3>Continuous limit<\/h3>\n<p>We can also compute the continuous limit as $n$ tends to infinity. To make sense of this, we\u2019ll imagine that \u201crolling an $n$-sided die\u201d is replaced by \u201cpicking a uniformly chosen random number in $[0,1]$\u201d. So the probability mass functions are replaced by probability densities. The derivations are essentially identical to those above, except the densities for the base case are:<br>\n\\[<br>\nf(z)=1, \\qquad F(z)=z, \\qquad \\bar F_k=1-z.<br>\n\\]\n<\/p><\/div>\n<p>And here are the results:<br>\n<a href=\"javascript:Solution('soln_dnd2','toggle_dnd2')\" id=\"toggle_dnd2\">[Show Solution]<\/a><\/p>\n<div id=\"soln_dnd2\" style=\"display: none\">\n<h3>Table of results<\/h3>\n<p>Here is a table containing the probability mass function (pmf), cumulative distribution (cmf), and complimentary cumulative distribution (ccmf) for the five combinations of advantage and disadvantaged dice rolls.<br>\n\\[<br>\n\\begin{array}{c|c|c|c}<br>\n\\text{case} &amp; \\text{pmf }f_k &amp; \\text{cmf }F_k &amp; \\text{ccmf }\\bar F_k \\\\ \\hline<br>\n\\text{A}+\\text{D} &amp; \\frac{1}{n} &amp; \\frac{k}{n} &amp; \\frac{n-k+1}{n} \\\\<br>\n\\text{A}          &amp; \\frac{2k-1}{n^2} &amp; \\frac{k^2}{n^2} &amp; \\frac{(n+k-1)(n-k+1)}{n^2} \\\\<br>\n\\text{D}          &amp; \\frac{2n-2k+1}{n^2} &amp; \\frac{k(2n-k)}{n^2} &amp; \\frac{(n-k+1)^2}{n^2} \\\\<br>\n\\text{A of D}     &amp; \\frac{(2 k-2 n-1) \\left(2 k^2-4 k n-2 k+2 n+1\\right)}{n^4} &amp; \\frac{k^2(2n-k)^2}{n^4} &amp; \\frac{(n-k+1)^2 \\left(n^2-k^2+2kn+2k-2 n-1\\right)}{n^4}\\\\<br>\n\\text{D of A}     &amp; \\frac{(2k-1) \\left(2n^2-2k^2+2k-1\\right)}{n^4} &amp; \\frac{k^2 \\left(2 n^2-k^2\\right)}{n^4} &amp; \\frac{(n+k-1)^2 (n-k+1)^2}{n^4} \\\\<br>\n\\end{array}<br>\n\\]And here is a table for the continuous case, containing the probability density function (pdf), cumulative distribution (cdf), and complimentary distribution (ccdf).<br>\n\\[<br>\n\\begin{array}{c|c|c|c}<br>\n\\text{case} &amp; \\text{pdf }f(z) &amp; \\text{cdf }F(z) &amp; \\text{ccdf }\\bar F(z) \\\\ \\hline<br>\n\\text{A}+\\text{D} &amp; 1 &amp; z &amp; 1-z \\\\<br>\n\\text{A}          &amp; 2z &amp; z^2 &amp; 1-z^2 \\\\<br>\n\\text{D}          &amp; 2-2z &amp; z(2-z) &amp; (1-z)^2 \\\\<br>\n\\text{A of D}     &amp; 4z(1-z)(2-z) &amp; z^2(2-z)^2 &amp; (1-z)^2(1+2z-z^2)\\\\<br>\n\\text{D of A}     &amp; 4z(1-z^2) &amp; z^2(2-z^2) &amp; (1-z^2)^2 \\\\<br>\n\\end{array}<br>\n\\]<\/p>\n<h3>Expected value<\/h3>\n<p>We can compute expected values as a function of $n$ by evaluating $\\sum_{k=1}^n k\\,f_k$ for each of the cases. We can also evaluate the continuous limit by computing $\\int_0^1 z\\,f(z)\\,\\mathrm{d}z$ for each case. I rearranged the columns so that they are sorted from largest to smallest.<br>\n\\[<br>\n\\begin{array}{c|c}<br>\n\\text{case} &amp; \\text{Expectation} &amp; \\text{Continuous limit} \\\\ \\hline<br>\n\\text{A}          &amp; \\frac{(n+1) (4 n-1)}{6 n} &amp; \\frac{2}{3} \\\\<br>\n\\text{D of A}     &amp; \\frac{(n+1) \\left(16 n^3-n^2+n-1\\right)}{30 n^3} &amp; \\frac{8}{15} \\\\<br>\n\\text{A}+\\text{D} &amp; \\frac{n+1}{2} &amp; \\frac{1}{2} \\\\<br>\n\\text{A of D}     &amp; \\frac{(n+1) (2 n+1) \\left(7 n^2-3 n+1\\right)}{30 n^3} &amp; \\frac{7}{15} \\\\<br>\n\\text{D}          &amp; \\frac{(n+1) (2 n+1)}{6 n} &amp; \\frac{1}{3} \\\\<br>\n\\end{array}<br>\n\\]Indeed, if we take the Expectation column $E$, which takes on values in $\\{1,\\dots,n\\}$, compute $\\frac{E-1}{n-1}$ in order to normalize the range of possible outcomes to $[0,1]$, then let $n\\to\\infty$, we recover the \u201cContinuous limit\u201d column. Here is a plot of this phenomenon in action.<\/p>\n<p><a href=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_expected.png\"><img decoding=\"async\" src=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_expected.png\" alt=\"\" width=\"1480\" height=\"765\" class=\"aligncenter size-full wp-image-2830\" loading=\"lazy\" srcset=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_expected.png 1480w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_expected-300x155.png 300w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_expected-1024x529.png 1024w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_expected-768x397.png 768w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_expected-1200x620.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/p>\n<p>Ultimately, we conclude that \u201cdisadvantage of advantage\u201d is better than \u201cadvantage of disadvantage\u201d. This idea that the \u201cminimums of maximums\u201d is always larger than the \u201cmaximum of minimums\u201d is actually a much more general notion that applies to arbitrary functions. The result is known as the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Max%E2%80%93min_inequality\">max-min inequality<\/a> and it states that for <em>any<\/em> function $f:Z\\times W \\to \\mathbb{R}$, we have:<br>\n\\[<br>\n\\inf_{w\\in W}\\sup_{z\\in Z}f(z,w) \\geq \\sup_{z\\in Z}\\inf_{w\\in W}f(z,w)<br>\n\\]<\/p>\n<h3>Rolling $k$ or better<\/h3>\n<p>If the task is to roll $k$ or better, then we are seeking the probability that our outcome $X$ satisfies $X \\ge k$. This is precisely the complimentary cumulative distribution function! Plotting these values for $n=6$, we obtain:<\/p>\n<p><a href=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccmf_6.png\"><img decoding=\"async\" src=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccmf_6.png\" alt=\"\" width=\"1455\" height=\"728\" class=\"aligncenter size-full wp-image-2831\" loading=\"lazy\" srcset=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccmf_6.png 1455w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccmf_6-300x150.png 300w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccmf_6-1024x512.png 1024w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccmf_6-768x384.png 768w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccmf_6-1200x600.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/p>\n<p>As anticipated, when $k=1$, all probabilities are $1$. The \u201cadvantage\u201d roll is always best, while \u201cdisadvantage\u201d is always worst. \u201cdisadvantage of advantage is second best for $k=1,2,3,4$, but for $k=5,6$ it\u2019s best to roll a single die. We observe a similar result when $n=20$:<\/p>\n<p><a href=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccmf_20.png\"><img decoding=\"async\" src=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccmf_20.png\" alt=\"\" width=\"1459\" height=\"724\" class=\"aligncenter size-full wp-image-2832\" loading=\"lazy\" srcset=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccmf_20.png 1459w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccmf_20-300x149.png 300w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccmf_20-1024x508.png 1024w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccmf_20-768x381.png 768w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccmf_20-1200x595.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/p>\n<p>This time, \u201cdisadvantage of advantage\u201d is second best for $1\\le k \\le 13$ and rolling a single die is best for $14 \\le k \\le 20$. In general, we can compute where the transition occurs as a function of $n$ by seeing which value of $k$ leads to $\\bar F^{\\text{DA}}_k = \\bar F_k$. This leads to the equation:<br>\n\\[<br>\n\\frac{(n+k-1)^2 (n-k+1)^2}{n^4} = \\frac{n-k+1}{n}<br>\n\\]Solving this equation for $k$ and discarding extraneous solutions, we find the threshold occurs at:<br>\n\\[<br>\nk_0 = 1 + \\left( \\frac{\\sqrt{5}-1}{2} \\right) n<br>\n\\]So if $1\\leq k &lt; k0$, we have $\\bar F^{\\text{DA}}_k \\gt \\bar F_k$ and if $k_0 \\lt k \\leq n$, we have $\\bar F^{\\text{DA}}_k \\lt \\bar F_k$. Ok, so what happens in the limit? We can plot the continuous complimentary cdfs and obtain:<\/p>\n<p><a href=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccdf.png\"><img decoding=\"async\" src=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccdf.png\" alt=\"\" width=\"1461\" height=\"724\" class=\"aligncenter size-full wp-image-2837\" loading=\"lazy\" srcset=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccdf.png 1461w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccdf-300x149.png 300w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccdf-1024x507.png 1024w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccdf-768x381.png 768w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2020\/05\/dnd_ccdf-1200x595.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/p>\n<p>The pattern is the same, and we can solve for the cross-over point as before, by setting $\\bar F^{\\text{DA}}(z) = \\bar F(z)$. This time, the equation is $(1-z^2)^2=1-z$. Solving for $z$, we obtain<br>\n\\[<br>\nz_0 = \\frac{\\sqrt{5}-1}{2}<br>\n\\]This is not surprising, as we could have simply normalized the discrete result as we did for expectations and take the limit $n\\to\\infty$ to obtain the same result. This number is the inverse of the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Golden_ratio\">Golden Ratio<\/a>, neat!\n<\/p><\/div>\n<p><\/p>\n<\/body>","protected":false},"excerpt":{"rendered":"<p>This week\u2019s Riddler Classic is a probability problem about the game Dungeons &amp; Dragons. Here it goes: When you roll a die \u201cwith advantage,\u201d you roll the die twice and keep the higher result. Rolling \u201cwith disadvantage\u201d is similar, except you keep the lower result instead. The rules further specify that when a player rolls &hellip; <a href=\"https:\/\/laurentlessard.com\/bookproofs\/dungeons-dragons\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Dungeons &#038; Dragons&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":2832,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[7],"tags":[8,2],"class_list":["post-2826","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-riddler","tag-probability","tag-riddler"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/posts\/2826","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/comments?post=2826"}],"version-history":[{"count":6,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/posts\/2826\/revisions"}],"predecessor-version":[{"id":2838,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/posts\/2826\/revisions\/2838"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/media\/2832"}],"wp:attachment":[{"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/media?parent=2826"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/categories?post=2826"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/tags?post=2826"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}