Probability of ending with 2 blue balls in a row after $n$ draws Thank you for taking the time to read my question.
The scenario is, we're playing a game where we have in a box 9 balls: 4 red, 3 green, 2 blue.
We draw one ball at a time, and note down its color and then return it for the next draw, the game stops only when we have drawn the same color twice in a row.

*

*What is the probability of the game ending after $n$ draws? $P(X=n)$?

*What is the probability of the last two balls being blue?

I have tried to treat it as a geometric probability distribution, with: p: probability of having two balls in a row with the same color $P(X=n) = n-1$ fails and then a success but this ball number 2 and 3 could be the same color in this. I've tried to discuss it case by case, starting with if the first ball is Blue, Red, Green, in hopes of noticing some recursion, but no luck. Haven't had any other ideas.
 A: Here is an idea how to solve the problem using the Markov's chain. Possibly it is not the simplest solution but it is general enough so that it can be applied to more complicated problems as well.
Let the probabilities to draw the balls be $p_1,p_2,p_3$, respectively and let the state of the sequence be characterized by the color (type) of the last ball. Then the transition matrix  and the initial state read:
$$
T=\left(\begin{array}{ccc|c}
0&  p_1& p_1&\color{grey}0\\
p_2&0&p_2&\color{grey}0\\
p_3&p_3&0&\color{grey}0\\
\hline
\color{grey}{p_1}&\color{grey}{p_2}&\color{grey}{p_3}&\color{grey}{1}
\end{array}\right)\quad\text{and}\quad 
P_1=\begin{pmatrix}
p_1\\
p_2\\
p_3\\
\color{grey}0\\
\end{pmatrix},\tag1
$$
respectively, and  the state of the sequence after $n$ draws is
$$
P_n=T^{n-1}P_1.\tag2
$$
To make the things simpler one can note that there is no back coupling from the final state, so that it can be omitted and only the action of the "active" $3\times3$ block of the matrix onto the $3\times1$ vector of "active" states [highlighted in $(1)$] be considered. In what follows these reduced versions of the transition matrix and the state vector are assumed.
The characteristic polynomial of the active block is:
$$
Q(x)=x^3-(p_1p_2+p_2p_3+p_3p_1)x-2p_1p_2p_3,\tag3
$$
so that the probability vector $P_{n}$ can be computed by the recurrence relation:
$$
P_{n}=(p_1p_2+p_2p_3+p_3p_1)P_{n-2}+2p_1p_2p_3P_{n-3}\tag4
$$
with the elements of the three initial state vectors being:
$$
P_{0,i}=\tfrac12,\quad P_{1,i}=p_i,\quad P_{2,i}=(1-p_i)p_i.\tag5
$$
Finally the probability of ending with two balls of $i$-th color after $n$-th draw is:
$$
P_{n-1,i}\cdot p_i.\tag6
$$
