Infinite expected value? An acquaintance of mine proposed a scenario.  Imagine parents who ground their child.  Initially, the grounding is for 5 days, but for every day the child misbehaves while they're grounded, the parents will tack on an extra 2 days.  The child is very predictable and has a 30% chance of misbehaving on any given day, no matter how long they've already been grounded.
What is the expected value for this poor kid's imprisonment?  When I look at the problem, I come up with $\infty$ because there's a non-zero chance he'll keep adding days on forever.  My acquaintance said this wasn't the case but can't prove it.
If the EV isn't $\infty$, can someone explain where I'm going wrong?  My probability knowledge is very old and rusty, unfortunately.
 A: Let $f(n)$ be the expected value of the remaining sentence given that the current sentence is $n$ days.  At the end of the day, the new sentence is either $n-1$ days if the kid behaved (with probability $0.7$), or $n+1$ days if the kid didn't behave (with probability $0.3$).  So
$$
f(n)=1+\frac{7}{10}f(n-1)+\frac{3}{10}f(n+1),
$$
with the boundary condition that $f(0)=0$.  Assuming a linear solution, $f(n)=An$, gives $$An=1+\frac7{10}(An-A)+\frac3{10}(An+A)=An+1-\frac25A$$ or $A=5/2$.  So the expected sentence is just $5/2$ times the current sentence, or $12.5$ days if the initial grounding was five days.
A: Expected # of days misbehaved = $0.3\times5 = 1.5$
Expected # of additional days tacked on = $2\times1.5 = 3$
so it is a G.P. with a = 5, r = $\dfrac35$ =0.6
$S_\infty = \dfrac{a}{(1-r)} = \dfrac{5}{0.4} = 12.5$
A: This answer comes in two parts:


*

*Show that the expectation is finite

*Calculate the expectation.


Showing the expectation is finite
Let's ignore the punishment for a moment and just consider the kids actions for all eternity. Each day, starting with day 1, the child is either good or bad, with probabilities 0.7 and 0.3 respectively.
Now, let's consider the following variation on counting days of the punishment: on day 0, we start a tally at 5. Each day, we either add or subtract one from the tally depending on whether the child was good or bad. This tally is allowed to reach zero or even go negative.
The question you ask is the expected day of the first zero, but that's a harder question: let's first ask about the probability that the tally on any particular day is positive. Let $T_n$ be the tally on day $n$. We have $T_0 = 5$.
It turns out that this tally is fairly easy to study. To get the tally on day $n$, let $G_n$ be the number of good days up to day $n$ and $B_n$ be the number of bad days. Then $G_n+B_n = n$, and the tally is $T_n = 5 + B_n - G_n$.
Thus, $T_n > 0$ if and only if $G_n \leq \lfloor (n+5)/2 \rfloor$.
It is easy to obtain the probability that $G_n=g$: it is
$$ \binom{n}{g} (0.7)^g (0.3)^{n-g} $$
This comes from there being $\binom{n}{g}$ different ways to pick which of the $n$ days were good, and each individual possibility has odds $(0.7)^g (0.3)^{n-g}$ of occurring.
Thus, the number of good days is given by a binomial distribution.
The probability that $G_n \leq \lfloor (n+5)/2 \rfloor$ converges to zero very quickly. There is no great loss if you justify everything in the rest of this section with "because this probability vanishes very quickly", but I will give a rigorous argument too.
The tail bounds listed at Wikipedia in fact say it decreases at least as fast as exponentially:
$$ P(G_n \leq (n+5)/2 ) < e^2 (e^{-2/25})^n $$
Now, the total length of the punishment is no bigger than the total number of days where the tally is positive. Since the odds that the tally is positive on the $n$-th days is strictly less than a Geometric series, the expected total is finite:
$$ \sum_{n=0}^{\infty} P(T_n > 0) <\sum_{n=0}^{\infty} e^2 (e^-{2/25})^n < 100$$
Thus, the expected length of the punishment must be finite too.
Finding the average
The answer by mjq starts with a decent idea; if $f(n)$ expresses the expected remainder of the punishment given that it's currently $n$ days, then
$$ f(n) = 1 + \frac{7}{10} f(n-1) + \frac{3}{10} f(n+1) \qquad \qquad f(0) = 0$$
There are standard ways to solve recursions of this form, which would be suitable for a new question. For those who know the methods, the main trick here is to write $f(n) = g(n) + An$ to account for that $1$, and then you have an ordinary linear difference equation.
The general solution to the recursion is
$$ f(n) = \frac{5n}{2} + A + B \left(\frac{7}{3} \right)^n $$
The condition $f(0) = 0$ lets us simplify to
$$ f(n) = \frac{5n}{2} + B \left( \left(\frac{7}{3} \right)^n - 1 \right)$$
Heuristically, exponential growth should be too fast, so we need $B=0$. A rigorous argument of this fact can be given by adapting the argument at the end of the previous section to show that $f(n) \in O(e^{2n/5})$.
So finally, the answer for the expected length of punishment is $f(5) = 25/2 = 12.5$.
Argument for linearity
Once we know the expectation is finite, there is an argument that it should be linear: if the punishment is $n$ days, then there is only one way the punishment can end: it can decrease to $m$ days, and then an $m$-day punishment can expire (where $0 \leq m \leq n$).
But that's the same as waiting for an $n-m$ day punishment to expire followed by an $m$-day punishment. Thus, we have to have $f(n) = f(n-m) + f(m)$. Consequently, $f(n) = n \cdot f(1)$.
