# Geometric distrubution and expectancy

I have following problem: We throw a fair dice time after time.What is time expectancy to get first time 66 i.e two six in the row for the first time. I probably should use this http://en.wikipedia.org/wiki/Expected_value#Discrete_distribution_taking_only_non-negative_integer_values though I don't understand how.

-
How often do you throw your dice? – Rasmus Jan 8 '11 at 10:14
Actually, you need the negative binomial distribution, which is a generalization of the geometric distribution. – Raskolnikov Jan 8 '11 at 10:29
@Ramsus I throw it continuously until I get the desired result.I need expectancy after how many throwing I get desired result – user5509 Jan 8 '11 at 10:32
I forgot there is a complicating factor here, you want the first occurance of two 6 in a row. So to compute the probability that you have to wait a time $n$ you will have to exclude earlier appearances of a double 6 which can be tricky to do. – Raskolnikov Jan 8 '11 at 10:36
@Raskolnikov I need expectancy to get it first time – user5509 Jan 8 '11 at 10:56

Let $x$ be the expected number of tosses to get one six. Then $x = \frac{5}{6}(1+x)+ \frac{1}{6}(1)$. So $x=6$. Let $y$ be the expected number of throws to two consecutive sixes. Then $y = \frac{1}{6}(x+1)+ \frac{5}{6}(x+1+y)$. So $y = 6(x+1)$. Plugging in $x=6$, we get $y = 42$.

-
Can you expand a bit on how you did it? It doesn't agree with my numerical simulations. The expected number of throws should be around 42. Besides, the expected number of tosses to get one 6 should be 6. – Raskolnikov Jan 8 '11 at 12:32
Yes the x is geometric random variable so x=6 so we get 42 – user5509 Jan 8 '11 at 12:34
@Raskolnikov: To get one six, you have to toss the die at least once. Then you can either get a six or get back $x$. To get 2 consecutive sixes, you either get a six in the $x+1$-st trial or you do not. – PEV Jan 8 '11 at 12:39
@Raskolnikov: I edited the formula for $x$. – PEV Jan 8 '11 at 12:49

Define a live n-sequence to be a sequence of $n$ dice throws in which no double 6 occurs. Define:

$r_n$ = number of live $n$-sequences that don't end in 6
$s_n$ = number of live $n$-sequences that do end in 6

Then we get the recurrence relations:

$r_{n+1} = 5r_{n} + 5s_{n}$
$s_{n+1} = r_n$

with initial conditions $r_0 = 1, s_0 = 0$. Substituting the second relation into the first gives

$s_{n+2} = 5s_{n+1} + 5s_{n}$

The solutions of this are of the form $s_n = A\alpha^n + B\beta^n$, where $\alpha$ and $\beta$ are the roots of the equation $x^2 - 5x - 5 = 0$:

$\alpha = (5 + 3\sqrt5)/2, \beta = (5 - 3\sqrt5)/2$

The probability that we need exactly $n$ throws is $\frac{1}{6} s_{n-1}/6^{n-1} = \frac{s_{n-1}}{6^n}$, so the expected number of throws is

$\sum_{n=1}^\infty n\frac{s_{n-1}}{6^n} = \frac{A}{\alpha}\sum_{n=1}^\infty nu^n + \frac{B}{\beta}\sum_{n=1}^\infty nv^n$

where $u = \frac{\alpha}{6}$ and $v = \frac{\beta}{6}$. This is

$\frac{A}{\alpha}\frac{u}{(1-u)^2} + \frac{B}{\beta}\frac{v}{(1-v)^2}$

From the initial terms $s_0=0, s_1=1$, we get $A = \frac{1}{3\sqrt 5}, B = -A$. So we get

$\frac{A}{6}(\frac{1}{(1-u)^2} - \frac{1}{(1-v)^2})$, which my shaky algebra simplifies to...wait for it...

$42$

-
Nice answer as well, a bit overkill compared to Trevor's, but it has the bonus of providing not only the expectation but the full probability distribution. – Raskolnikov Jan 8 '11 at 13:39

The probability that you get a 6 after $n+1$ throws is $$\frac{5^n}{6^n} \frac{1}{6}$$ that is getting $n$ times something else than a $6$ then getting a $6$. Therefore, the probability to throw $n$ times the dice and then to get two $6$ in a row is $$\frac{5^n}{6^n} \frac{1}{6^2}.$$ The expectancy is thus $$\frac{1}{6^2} \sum_{n=0}^{\infty}\frac{5^n}{6^n}.$$