# Rolling a die

## Homework Statement

a fair die is tossed n times
let X be the number of times that the pattern 1 2 is observed
(a) E(X) (b) VAR(X)

(it's a question from a past exam)

## The Attempt at a Solution

E(X)=E(E(X|first=1)+E(X|first ≠ 1))
let E(X)=f(n)
f(n)=((1+f(n-2))*(1/6)+(5/6)*f(n-1))*(1/6)+f(n-1)*(5/6)
I think I'm setting up the equation wrong since I got something other than 12/(6^3) as I plug in n=3.
However, even if I set it up correctly, I still have no idea how to solve this equation....
Any help would be greatly appreciated.

## Answers and Replies

HallsofIvy
Science Advisor
Homework Helper
What do you mean by "the pattern 1 2"?

Ray Vickson
Science Advisor
Homework Helper
Dearly Missed

## Homework Statement

a fair die is tossed n times
let X be the number of times that the pattern 1 2 is observed
(a) E(X) (b) VAR(X)

(it's a question from a past exam)

## The Attempt at a Solution

E(X)=E(E(X|first=1)+E(X|first ≠ 1))
let E(X)=f(n)
f(n)=((1+f(n-2))*(1/6)+(5/6)*f(n-1))*(1/6)+f(n-1)*(5/6)
I think I'm setting up the equation wrong since I got something other than 12/(6^3) as I plug in n=3.
However, even if I set it up correctly, I still have no idea how to solve this equation....
Any help would be greatly appreciated.

The following suggestions may be helpful (if you know something about Markov chains) or incomprehensible if you don't know Markov chains. Anyway, you can reduce it to a standard expected-cost calculation in a 3-state Markov chain. The three states are (1) state 1 (start, or start again); (2) state 2 (have tossed '1'); and (3) state 3 (have just achieved pattern '12'). We are in state 1 to start (before tossing). From state 1 we go go state 1 with probability 5/6 and to state 2 with probability 1/6. Frorm state 2 we go to state 1 with probability 4/6 (if we toss 3,4,5,6), to state 1 with probability 1/6 (if we toss 1, so throw out the previous '1' result and start another possible pattern), and to state 3 with probability 1/6 (if we toss '2'). From state 3 we go to state 1 with probability 5/6 and to state 2 with probability 1/6.

Your random variable X is the number of times we visit state 3 in N tosses. We can regard this as an expected cost problem, where we pay \$1 each time we hit state 3, and we are interested in the mean and variance of N-period cost. There are standard formulas that can be applied; these can be found in many sources dealing with Markov chains, but will not usually be found in introductory probability textbooks, for example.

RGV