Sum of dice rolls conditioned on parity A fair 6-sided die is rolled until a 6 shows up. Let $S$ denote the sum of all rolls and let $P$ denote the parity of $S$. Find $\mathbb{E}[S|P=0]$.

There are several directions one can approach this. I would prefer a clean solution if possible (one idea is to write out a summation for the expectation and simplify it algebraically, but this seems messy). Here are some of my thoughts:

*

*From total expectation, we can write
$$\mathbb{E}[S]=\mathbb{E}[S|P=0]\mathbb{P}(P=0)+\mathbb{E}[S|P=1]\mathbb{P}(P=1)$$
We can compute $\mathbb{E}[S]$ via
$$\mathbb{E}[S]=6+\mathbb{E}[\sum_{i=1}^TX_i]=6+\mathbb{E}[T]\mathbb{E}[X_1]=6+5\cdot 3=21$$
where $T$ denotes the number of rolls before the 6 and $X_1,X_2,\dots,X_T$ denote the value of the rolls. We can also easily compute $\mathbb{P}(P=0)=\frac{4}{7},\mathbb{P}(P=1)=\frac{3}{7}$ by solving a system of linear equations. So if we can compute the ratio of $\mathbb{E}[S|P=0]$ and $\mathbb{E}[S|P=1]$ somehow, we would be done.


*We can try to compute $$\mathbb{E}[S|P=0]=6+\mathbb{E}[\sum_{i=1}^TX_i|P=0]$$
directly. Would we be able to simplify this as
$$\mathbb{E}[\sum_{i=1}^TX_i|P=0]=\mathbb{E}[T|P=0]\mathbb{E}[X_i|P=0]$$
since I believe $X_i$ and $T$ are still independent conditioned in $P$? But even if this is correct, I don't see how to get $\mathbb{E}[T|P=0]$ without a messy summation.


*There may be a tricky solution which uses iterated expectation, adding an extra conditional on $T$. I haven't thought about this too much though.
Any ideas would be appreciated!
 A: For convenience of notation, let $\alpha := \mathbb E[S \cdot \mathbf 1_{P=0}]$ and $\beta := \mathbb E[S \cdot \mathbf 1_{P = 1}]$. We note that $\mathbb E[S] = \alpha + \beta$, and that
\begin{align*}
  \mathbb E[S \mid P = 0] & = \alpha / \mathbb P(P = 0) = \alpha \cdot \frac 7 4, \\
  \mathbb E[S \mid P = 1] & = \beta / \mathbb P(P = 1) = \beta \cdot \frac 7 3.
\end{align*}
Our goal is to obtain an additional relationship between $\alpha, \beta$. The big idea is that if we condition on the first step of this process, then one of three things will happen:

*

*we roll a 2 or 4, meaning the problem "starts over" and the parity is unchanged

*we roll a 1, 3, or 5, meaning the problem "starts over" and the parity flips

*we roll a 6, and the process terminates

This idea, combined with a Markov approach, will give us what we need:
\begin{align}
  \underbrace{\mathbb E[S \cdot \mathbf 1_{P =0 }]}_{\alpha} &=
  \mathbb E[S \mathbf 1_{P=0} \mathbf 1_{X_1 \in \{1, 3, 5\}}] + \mathbb E[S \mathbf 1_{P=0} \mathbf 1_{X_1 \in \{2, 4\}}] + \mathbb E[S \mathbf 1_{P=0} \mathbf 1_{X_1 = 6}] \\
&= \mathbb E[S \mathbf 1_{P=0} \mid X_1 \in \{1, 3, 5\}] \cdot \mathbb P(X_1 \in \{1, 3, 5\}) \\
& \qquad + \mathbb E[S \mathbf 1_{P=0} \mid X_1 \in \{2, 4\}] \cdot \mathbb P(X_1 \in \{2, 4\}) \\
& \qquad + \mathbb E[S \mid \mathbf 1_{P=0, X_1 = 6}] \cdot \mathbb P(P = 0, X_1 = 6)
\end{align}
The last of these three terms is the most straightforward; it's $6 \cdot 1/6 = 1$. For the first of the three terms, we note that the average value of $X_1$ is $3$, and since $X_1$ was odd, we now need the parity of the remaining terms $2, \dots, T$ to be odd; thus, $\mathbb E[S \mathbf 1_{P = 0} \mid X_1 \in \{1, 3, 5\}] = \mathbb E[(S+3) \cdot \mathbf 1_{P = 1}]$. (NB: I'm skipping some rigorous details to focus on the big picture, but this is just a Markov argument; given that the process did not terminate on step one, its future looks the same as it originally did, except now we want the opposite parity of the remaining terms.) The second term can be treated similarly; the average value of $X_1$ is again $3$, but this time we need the remaining terms' parity to still be even in order for the full sum to be even, so we have $\mathbb E[S \mathbf 1_{P = 0} \mid X_1 \in \{2, 4\}] = \mathbb E[(S + 3) \cdot \mathbf 1_{P = 0}]$. Putting this all together in the above gives
\begin{align*}
  \alpha &= \mathbb E[(S+3) \mathbf 1_{P = 1}] \cdot \frac 1 2 + 
            \mathbb E[(S+3) \mathbf 1_{P = 0}] \cdot \frac 1 3 + 1 \\
  &= \frac 1 2 \beta + \frac 3 2 \mathbb P(P = 1) + \frac 1 3 \alpha + \frac 3 3 \mathbb P( P = 0) + 1 \\
  &= \frac 1 2 \beta + \frac 9 {14} + \frac 1 3 \alpha + \frac 4 7 + 1
\end{align*}
and solving this equation along with $\alpha + \beta = 21$ gives $\alpha = \frac{534}{49}$, whence $\mathbb E[S \mid P = 0] = \alpha \cdot \frac 7 4 = \fbox{$\frac{267}{14} \approx 19.0714$}$, which confirms the simulations of @quasi. I'll also note that I have independently confirmed this calculation with my own simulation.
