below question is quite some annoying and don`t know how to solve it
I tried to deal with the below question for the day but don`t know how to approach for this kind question
your help will be higly appreciated
suppose the box which contains 3 ball : red, green and blue ball
for one trial, pick a ball and record its color in note
(the probability of picking a ball is all same(independent))
if there exist consecutive result of rgb came out, then add bold r in the last record
ex)
1st trial : red ball -> record : r
2nd trial : green ball -> record : rg
3rd trial : blue ball -> record : rgb -> add : rgbr
4th trial : green ball -> record : rgbrg
5th trial : blue ball -> record : rgbrgb -> add : rgbrgbr
6th trail : red ball -> record : rgbrgbrr
...
How to find the expectation of number of bold r in n trial?
For each nonnegative integer $n$, let $e(n)$ be the expected number of ocurrences of bold "r" in $n$ trials.
I'm not sure if a closed form for $e(n)$ is achievable, but $e(n)$ can be computed recursively as follows . . .
For each pair $(n,k)$ of nonnegative integers with $k\le 2$, let $f(n,k)$ be the expected number of ocurrences of bold "r" in $n$ trials, assuming a current match of the first $k$ characters of "rgb".
Then $e(n)=f(n,0)$, and $f$ satisfies the recursion $$ f(n,k)= \begin{cases} \text{if}\;\,n=0\;\text{then}\\[4pt] \qquad\;0\\[4pt] \text{else if}\;k=0\;\text{then}\\[4pt] \qquad\frac{1}{3}f(n-1,1)+\frac{2}{3}f(n-1,0)\\[4pt] \text{else if}\;k=1\;\text{then}\\[4pt] \qquad\frac{1}{3}f(n-1,2)+\frac{1}{3}f(n-1,1)+\frac{1}{3}f(n-1,0)\\[4pt] \text{else if}\;k=2\;\text{then}\\[4pt] \qquad\frac{1}{3}(1+f(n-1,1))+\frac{1}{3}f(n-1,1)+\frac{1}{3}f(n-1,0)\\ \end{cases} $$ Applying the recursion for some selected values of $n$, we get \begin{align*} e(10)&=\frac{6356}{19683}\approx .3229182543\\[4pt] e(20)&=\frac{859589210}{1162261467}\approx .7395833334\\[4pt] e(30)&=\frac{79353873828146}{68630377364883}\approx 1.156250000\\[4pt] e(40)&=\frac{6374331542769431420}{4052555153018976267}\approx 1.572916667\\[4pt] e(50)&=\frac{476105957115082793246936}{239299329230617529590083}\approx 1.989583333\\[4pt] \end{align*}