Monday 18 April 2016

probability - Expected number of die rolls for Tyche's die



Tyche's die is a custom D&D magic item that I'm working on. The part of its functioning which is relevant to this question is as follows:
Tyche's die can have 2, 4, 6, 8, 12, or 20 faces. If not 20-sided, when you roll the maximum score on the die, it transforms into the next stage (coin becomes tetrahedron, tetrahedron becomes cube and so-on). If not a coin, when you roll a 1, it transforms into the previous stage (icosahedron becomes dodecahedron, dodecahedron becomes octahedron and so-on).




The objective being of rolling a $20$, and assuming it starts as a coin, how many times can I expect to roll the die before that occurs?



More generally, given a set of $n$ dice ${d_1,...d_n}$ with numbers of faces $f_1,...,f_n$; given the probability of changing from the die $d_k$ to the die $d_{k+1}$ or $d_{k-1}$ is $\frac{1}{f_k}$; and given $f_{k-1}, starting with $d_1$, what is the number of die rolls I can expect to make before rolling $f_n$?



I wrote a Python script which simulated the specific version of the problem for me $300,000$ times and it seems to be around $124.4$, with a standard deviation of about $95$. However, I'm not sure how to go about solving this analytically.



I came up with trying to decompose the problem by solving it assuming we only have the two last dice and then adding dice progressively. However, even then I'm not sure how to take into account the probability of undoing progress.


Answer



You have a Markov chain. Let $E(n)$ be the expected number of rolls to get a $20$ given that your are rolling an $n$ sided die. You can set up a set of simultaneous equations. The first is $$E(20)=\frac 1{20}+\frac {18}{20}(E(20)+1)+\frac 1{20}(E(12)+1)$$
because you have $\frac 1{20}$ chance of rolling $20$ and being done, $\frac {18}{20}$ chance of adding one roll and being just where you started, and $\frac 1{20}$ chance of getting a $1$ and dropping back to a $12$ sided die. The next is

$$E(12)=\frac 1{12}(E(20)+1)+\frac {10}{12}(E(12)+1)+\frac 1{12}(E(8)+1)$$
and so on. I fed it to Alpha with $a=E(20)$ and so on and got
$$E(20) = 52, E(12) = 84, E(8) = 104, E(6) = 116, E(4) = 122, E(2) = 124$$
in agreement with your simulation


No comments:

Post a Comment

real analysis - How to find $lim_{hrightarrow 0}frac{sin(ha)}{h}$

How to find $\lim_{h\rightarrow 0}\frac{\sin(ha)}{h}$ without lhopital rule? I know when I use lhopital I easy get $$ \lim_{h\rightarrow 0}...