0

This is a self-answer question that revisits this low quality posting.

MathSE answers have an upper bound on the size of this answer. So, I split the self-answer into two parts, Part-1 and Part-2.

As discussed below, I have my own motivations for judging the problem worthwhile, so I am revisiting the problem.

$~\underline{\text{The Problem}}$

A fair die is rolled until 3 consecutive 4's appear. What is the expected # of 2's and 3's that are rolled before the 3 consecutive 4's appear?

Edit
Assuming that I made no analytical errors within the "Sanity Checking - Method-2 : Probability-Oriented Recursion Analysis" section, near the end of the Part-2 answer, then the numerical answer is exactly $~86.$

$~\underline{\text{My Math Background}}$

B.A. in math, 1975. In the early 1970's, I took an introductory course in probability, but have forgotten most of it. Several decades ago, I worked through chapter 10 (quadratic reciprocity) in "Elementary Number Theory" by Uspensky and Heaslett (1938). Again, I have forgotten much of it.

$~\underline{\text{General Approaches To The Problem}}$

Given that I lack formal training here, my knowledge of possible approaches to this problem is very informal. The three approaches that occur to me are:

  • Method-1
    A recursion approach.

  • Method-2
    A probability-oriented recursion approach similar to the answer of Rob Pratt, in this problem. Note that the linked problem refers to any $~3~$ 4's, while this self-answer question is focusing on $~3~$ consecutive 4's.

  • Method-3
    This method will use Inclusion-Exclusion, with Stars and Bars used internally. Most of my self-answer will represent Method-3 generated analysis.

For what's its worth, I regard Method-3 as definitely inferior to either Method-1 or Method-2, specifically because its analysis is convoluted, and the resulting final computation is convoluted.

For the purposes of sanity-checking, at the end of my self-answer, after I have provided a closed form solution generated by Method-3 analysis, I am going to provide sanity-checking sections that provide a table of Method-3 results through $~n = 30,~$ demonstrate the equivalence of the Method-1 and Method-3 results through $~n = 30,~$ and (apparently) solve the problem with Method-2. I see value in all of this sanity-checking, which is part of my motivation.

However, part of my motivation is also to consider Method-3, specifically.

$~\underline{\text{Motive For Discussing Method-3}}$

Since I regard Method-3 as inferior, what is the value of providing Method-3?

See this article for an introduction to Inclusion-Exclusion. Then, see this answer for an explanation of and justification for the Inclusion-Exclusion formula.

Following the syntax in the second link, immediately above, for problems of this nature, Inclusion-Exclusion is generally regarded as unwieldy, specifically because considerations of symmetry break down when computing $~T_2, ~T_3, ~\cdots ~.$

However, the situation is not that simple.

For this type of problem, often (and this specific problem is no exception), Stars and Bars theory may be used internally to facilitate analytical (rather than manual) computation of each of $~T_2, ~T_3, \cdots.$

For Stars and Bars theory, see this article and this article.

For corresponding illustrative problems, see this answer, this answer, or Method 2 only of this answer.

With respect to my consideration of Method-3 in the self-answer, I also have a 2nd (hidden) motive, for broaching this subject.

I discussed the exact same subject by providing a long-winded comment in an answer box to this low quality question, which is closed and will (presumably) soon be deleted.

Note that since the question referred to in the previous paragraph is a low quality question, it doesn't permit answers. Also, note that the low quality question in the previous paragraph has some aspects that are similar to this self-answer posted question, which I will attack via Inclusion-Exclusion.

So, assuming that the "10 coin flips to get 3 in a row" question, which is now closed, will soon be deleted, this self-answer question preserves and (moderately) extends my expressing my analysis, which pertains to the concealed viability of Inclusion-Exclusion, when coupled with the internal use of Stars and Bars.

$\underline{\text{Defects In The Method-3 Inclusion Exclusion Approach}}$

In the Part-2 portion of the self-answer, see the very last section, "Sanity Checking - Method-3 Defects", for discussion.

user2661923
  • 42,303
  • 3
  • 21
  • 46
  • What numerical answer do you get in the end? – lulu Jun 29 '24 at 21:05
  • @lulu See the "Sanity Checking - Method-2 : Probability-Oriented Recursion Analysis" section, near the end of the Part-2 answer, where I compute an answer of exactly $~86.~$ It is unclear whether I have made an analytical mistake in this section. – user2661923 Jun 29 '24 at 22:01
  • Doing it quickly, I get $91.89872833$ but it's a fairly error prone computation. I'll post the quick solution, which just follows the lines laid out in my comments to the first version of this question. As I say, it's perfectly possible I have an arithmetic error. – lulu Jun 29 '24 at 22:03
  • @lulu Independent of my analysis, are you able to validly conclude that $~\displaystyle \sum_{n=3}^\infty \left[ ~P(n) \times R(n) ~\right]~$ is a convergent series? Also, in you opinion, is there an analytical error in the "Sanity Checking - Method-2 : Probability-Oriented Recursion Analysis" section? – user2661923 Jun 29 '24 at 22:05
  • I did not try to follow your method, finding it a bit roundabout. Should note, though, that I have already found one error in what I initially wrote. I neglected to take into account the fact that the string prior to $444$ can not end in $4$, as that would get us the $444$ sooner than expected. That is easily accounted for and I have made the relevant edit. – lulu Jun 29 '24 at 22:17
  • I think the expected number of users who will read all the way through your question and all your answers, paying close attention to all details, is zero. This is the kind of work you'd have to pay someone to do for you. – Gerry Myerson Jun 30 '24 at 09:36
  • @GerryMyerson If you are referring to all of the work, then I completely agree. I did try to shorten the exposition, but I found that there were so many places where readers might be confused as to what I was trying to do that I felt that I had to be long-winded for clarity. Alternatively, if you are referring to the ""Sanity Checking - Method-2 : Probability-Oriented Recursion Analysis" section, near the end of Part-2, that section is not that long. – user2661923 Jun 30 '24 at 15:08
  • @GerryMyerson Anyway, the point of this self-answer was to preserve my collected analysis that Inclusion-Exclusion, when coupled with Stars and Bars, is (perhaps surprisingly) often viable. This way, in future situations, I can simply refer readers to this article. Then, those (few) that are interested, can read it at their leisure. – user2661923 Jun 30 '24 at 15:11

6 Answers6

3

You have correctly calculated the average number of throws to $444$: $E_0=258$. All you need is to multiply it by probability $2/6$ of obtaining 2 or 3 in any particular throw. Hence you get $258/3=86$.

At first it seems that this is only an approximation, as final throws should be $444$ and can't be equal to $2$ or $3$. But that is an exact answer!

Let's see it.

Imagine you are doing your experiment of throwing a dice until $444$ appears. Than you do it again. Than again and again and again. You count the total number of $2$, $3$ and the total number of experiments completed.

Now imagine an observer who does not know your rules. She observes you from faraway in a binocular. What she will see? A strange guy who repeatedly throws a dice. Let's denote by $n$ the number of dice thrown, by $X_{en}$ — the number of completed experiments, by $X_{2n}$ and $X_{3n}$ the number of $2$ and $3$.

You are interested in the limit $(X_{2n} + X_{3n})/X_{en}$ (the average number of 2 or 3 per completed experiment).

$$ \frac{X_{2n} + X_{3n}}{X_{en}} = \frac{X_{2n} + X_{3n}}{n} \frac{n}{X_{en}} $$

The term $\frac{X_{2n} + X_{3n}}{n}$ tends to $2/6$. The term $\frac{n}{X_{en}}$ tends to $258$, as it's the average length of an experiment.

Hope this intuition helps!

Roah
  • 2,142
1

Note: the present version corrects a couple of computational errors in prior drafts. To be sure, trapping a couple of errors hardly precludes the possibility that others remain.

Outline: Find the expected number of tosses until $444$ is observed. Compute the expected number of $4's$ we will see prior to $444$. Then remark that the other prior tosses are equally likely to be any of the five non-$4$ values.

The expected number of tosses until $444$ is seen (including those three) can be computed via states. Labeling by the states by the length of the current string of $4's$ we can read off that $$E_{0}=1+\frac 56\times E_{0}+\frac 16\times E_1$$

$$E_1=1+\frac 56\times E_0+\frac 16\times E_2$$

$$E_2=1+\frac 56\times E_0$$

Which is easily solved to yield $E_0=258$ (that's the only one we care about).

Now, of the $255$ seen prior to $444$, how many do we expect to be $4$? Keep in mind that we can't have a streak of three consecutive $4's$ there. Note too that the last entry in that string can not be a $4$ (else we'd get the $444$ earlier than expected). Thus we aer trying to compute the expected number of $4's$ seen in a string of length $255$ with no $444's$ and which ends in $X$ for some $X\in \{1,2,3,5,6\}$. That is the same as the expected number of $4's$ seen in a sequence of length $254$ with no $444's$

Let $e_n$ denote the expected number of $4's$ to be found in a string of length $n$ without $444$. To handle the conditioning, we let $A_n$ be the number of such strings which start with $X$, $B_n$ the number which start with $4X$, and $C_n$ the number which start with $44X$. Finally, let $T_n$ be the total number of good strings of length $n$, so $T_n=A_n+B_n+C_n$. Recursively, $$A_n=5T_{n-1}\quad B_n=5T_{n-2}\quad C_n=5T_{n-3}\quad T_n=5(T_{n-1}+T_{n-2}+T_{n-3})$$

We then get, recursively, $$e_n=\frac {A_n}{T_n}\times e_{n-1}+\frac {B_n}{T_n}(e_{n-2}+1)+\frac {C_n}{T_n}(e_{n-3}+2)$$

which quickly implies that $e_{254}=39.9994291$. There is some possibility of rounding error, though I'd have thought these calculations were quite sharp.

That means we expect $255-39.9994291$ non-$4$ numbers prior to getting $444$. Of course, each non-$4$ number is equally likely to be seen, making the expected number of $2's$ plus $3's$: $$\frac 25\times (255-39.9994291)=\boxed {86.0002284}$$

I remark that this aligns with others of the provided solutions and with the simulation. I don't see why the answer ought to be an integer and, as I said, I'd have thought that the numerical computation was quite sharp, but of course it is possible that rounding errors have built up.

lulu
  • 76,951
  • As I say, an arithmetic error would not surprise me. For the $E_i$: Note that $E_i$ can only transition to $E_0$ (by throwing $X$) or to $E_{i+1}$ (by throwing $4$). Thus $E_i=\frac 56\times (E_0+1)+\frac 16\times (E_{i+1}+1)=1+\frac 56\times E_0+\frac 16\times E_{i+1}$. Of course $E_3=0$. I suspect the error, if error there be is in the other recursion, or in its numerical computation. – lulu Jun 30 '24 at 07:10
  • Yes, of course. My probabilities don't add to $1$. I neglected to account for the fact that, as we know there are no $444$ blocks, I must divide by the sum of the probabilities (we are asking for the expected number conditioned on the fact that we are in a no-$444$ sequence). Thus, in the second recursion, I must divide throughout by $\frac 56+\frac 5{6^2}+\frac 5{6^3}$. When that error is corrected, I get $86.055594$. I'll edit accordingly. To be sure, having found one error does not preclude the existence of others. – lulu Jun 30 '24 at 07:18
  • I think I'll delete this for now, and rethink it in the morning. Still not sure that modified recursion captures the conditional correctly. – lulu Jun 30 '24 at 07:43
  • Fixed it. This type of conditioning is notoriously tricky and I was unwisely trying to short circuit the computation. Anyway, I now get very close to $86$. Since I need to do a $254$ step recursion with awkward numbers, it is obviously possible that rounding errors account for the small difference, though I really don't see why the answer ought to be an integer. – lulu Jun 30 '24 at 10:09
  • For a good illustration of the difficulties in this sort of conditioning, I refer to this example – lulu Jun 30 '24 at 10:15
  • +1 : to your answer, which I have now read and understood, all the way through. I am assuming that you wrote a computer program to perform the recursion computations for $~e_n,~$ and that each of your calculations carried $~8 - 10~$ decimal places. I wonder what the result would be if you had each such calculation instead carry $~20~$ or more decimal places. If needed, Java (for example) has the BigInteger and BigDecimal classes, and I have been told that languages like C or Python offer similar facilities. – user2661923 Jun 30 '24 at 16:12
  • Yes, I made no effort to optimize the recursion and of course there are some large numbers involved, so perhaps the errors matter. – lulu Jun 30 '24 at 16:15
  • I wrote a Magma script to carry out your calculation in exact rational arithmetic. The result was $39.9994290739$, correct to $10$ decimal places, thus confirming your calculation. However, while I agree that your procedure should give you a reasonable approximation to the right answer, I'm not convinced that it will give you the exact value. – lonza leggiera Jul 02 '24 at 02:49
  • 1
    You can get the exact value by modelling the process as a Markov chain with an absorbing state, and using standard procedures to calculate the expected number of times another state is visited before absorption. When I did this, I obtained the same answer as the OP's method $3$—i.e. $86$. – lonza leggiera Jul 02 '24 at 02:52
  • @lonzaleggiera "When I did this, I obtained the same answer as the OP's method-3" : I think that you intended : "the same answer as the OP's Method-$\color{red}{\text{2}}$". – user2661923 Jul 02 '24 at 04:45
  • @user2661923 It looks like I must have misremembered where the part of your answers I was referring to appeared. It was under the heading "Sanity Checking - Method-2" of your second answer, which was the only part of either of your answers that I've actually read. – lonza leggiera Jul 02 '24 at 06:40
0

A fair die is rolled until 3 consecutive 4's appear. What is the expected # of 2's and 3's that are rolled before the 3 consecutive 4's appear?

I necessarily split my self-answer into two parts. Part-1 is in this answer box.

Method-3, which is (moderately) discussed in my posted self-answer question, will be used in this answer. My Method-3 approach will use both Inclusion-Exclusion theory and Stars and Bars theory.

See this article for an introduction to Inclusion-Exclusion. Then, see this answer for an explanation of and justification for the Inclusion-Exclusion formula.

For Stars and Bars theory, see this article and this article.

For any sequence of $~n~$ die rolls, I will read the die roll positions from left to right, so that the leftmost die roll position represents die roll $~1,~$ and the rightmost die roll position represents die roll $~n.~$ I will refer to any die roll position that is forced to be a $~4~$ by 4, any die roll position that is forced to not be a $~4~$ as Not-4, and any die roll position that is not forced to be a $~4,~$ but that may be a $~4~$ by U.

I am going to use the expression $~E(n)~$ to denote the event that the first occurrence of 3 consecutive die rolls of 4 occurs specifically on die rolls $~n-2, ~n-1, ~$ and $~n.~$ This implies (among other things) that for $~n \geq 4,~$ that die rolls $~n-3, ~n-2, ~n-1, ~$ and $~n~$ must specifically be Not-4, 4, 4, 4, respectively.

For any $~n \geq 3,~$ I will let:

  • The set $~A~$ denote the set of all possible $~n$-length die rolls, which implies that $~| ~A ~| = 6^n.$
  • The set $~B~$ denote the subset of A, where event $~E(n)~$ occurred.
  • The function $~P(n)~$ denote the probability that event $~E(n)~$ occurred, which implies that $~P(n) = \dfrac{|~B~|}{| ~A ~|}.$
  • The function $~R(n)~$ denote the average number of 2's and 3's that occurred on the die rolls, under the assumption that event $~E(n)~$ occurred. This implies that the function $~R(n)~$ denotes the average number of 2's and 3's that occurred in the $~n$-length die rolls in set $~B.$

Then, the desired computation will be

$$\sum_{n = 3}^\infty [ ~P(n) \times R(n) ~].$$

Note that at this point, it is unknown whether the series represented above is convergent or divergent.

Note also that for $~n \geq 7,~$ when identifying set $~B,~$ you must reject any $~n$-length die roll that causes 3 consecutive die rolls equal to 4 to occur anywhere within die rolls $~1~$ through $~(n-4).~$ This implies that you are rejecting any $~n$-length die rolls that have 3 consecutive 4's, starting in any of the die roll positions $~1~$ through $~(n-6).$

In the next section, I am going to manually compute the product $~[ ~P(n) \times R(n)~] ~$ for each value of $~n \in \{3,4,5,6,7\}.$

Part-1 will then end with the "General Considerations For Inclusion-Exclusion" section.

In Part-2:

In the subsequent sections in this answer that precede the sanity-checking sections, I will continue to develop an analytical approach to using Inclusion-Exclusion to compute the product $~[ ~P(n) \times R(n)~] ~$ for each $~n \geq 8.~$

Then, I will put this all together to provide a Method-3 generated closed form computation of $~[ ~P(n) \times R(n) ~], ~$ for any $~n \in \Bbb{Z_{\geq 3}}.$

Then, the sanity-checking sections will follow.


$\underline{\text{Manual Computations Of} ~[P(n) \times R(n)] ~\text{For} ~n \in \{3,4,5,6,7\}}$

In this section, the following shortcut will be taken to compute $~R(n).~$ If a specific $~n$-length die roll is characterized so that $~x~$ of the die rolls are labeled U and $~y~$ of the die rolls are labeled Not-4, (with the remainder of the die rolls in the group being labeled 4), then the average number of 2's and 3's, for this $~n$-length die roll will be

$$\frac{2x}{6} + \frac{2y}{5}.$$

$E(3)~$ is uniquely represented by the die rolls 4,4,4, which implies that $~R(3) = 0. ~$ Therefore,

$$P(3) \times R(3) = 0.$$

To compute $~[P(4) \times R(4)],~$ note that of the $~6^4~$ possible $~4$-length die rolls, only the Not-4, 4, 4, 4 die rolls will cause event $~E(4)~$ to occur. Therefore,

$$P(4) \times R(4) = \dfrac{5}{6^4} \times \frac{2}{5} = \frac{2}{6^4}.$$

To compute $~[P(5) \times R(5)],~$ note that of the $~6^5~$ possible $~5$-length die rolls, only the U, Not-4, 4, 4, 4 die rolls will cause event $~E(5)~$ to occur. Therefore,

$$P(5) \times R(5) = \frac{6 \times 5}{6^5} \times \left[ ~\frac{2}{6} + \frac{2}{5} ~\right]$$

$$ = \frac{6 \times 5}{6^5} \times \frac{22}{6 \times 5} = \frac{22}{6^5}.$$

To compute $~[P(6) \times R(6)],~$ note that of the $~6^6~$ possible $~6$-length die rolls, only the U, U, Not-4, 4, 4, 4 die rolls will cause event $~E(6)~$ to occur. Therefore,

$$P(6) \times R(6) = \frac{6^2 \times 5}{6^6} \times \left[ ~\frac{4}{6} + \frac{2}{5} ~\right]$$

$$ = \frac{6^2 \times 5}{6^6} \times \frac{32}{6 \times 5} = \frac{6 \times 32}{6^6} = \frac{192}{6^6}.$$


To compute$~P(7)],~$ of the $~6^7~$ possible $~7$-length die rolls, all of the U, U, U, Not-4, 4, 4, 4 $~7$-length die rolls except (specifically) 4,4,4,Not-4,4,4,4 will cause event $~E(7)~$ to occur. Therefore, for $~n = 7,~$ the corresponding set $~B~$ may be expressed as

$$B = \{ ~\text{U U U Not-4 4 4 4} ~\} \setminus \{ ~\text{4 4 4 Not-4 4 4 4} ~\},$$

with

$$P(7) = \frac{| ~B ~|}{6^7}.$$

I will compute $~R(7)~$ as

$$\frac{\text{total number of occurrences of a 2 or a 3 in any} ~7\text{-length die roll in set} ~B}{| ~B ~|}.$$

I will compute the numerator of the above fraction as the corresponding computation for the set $~\{ ~\text{U U U Not-4 4 4 4} ~\}~$ minus the corresponding computation for the set $~\{ ~\text{4 4 4 Not-4 4 4 4} ~\}.$ Further, when performing the computation for the set $~\{ ~\text{U U U Not-4 4 4 4} ~\},~$ I will examine each of the first $~4~$ die roll positions separately.

For die roll position $~1~$ of the set $~\{ ~\text{U U U Not-4 4 4 4} ~\},~$ you are (in effect) enumerating [2 or 3] U U Not-4 4 4 4, which computes to $~2 \times 6^2 \times 5.~$ By considerations of symmetry, you get the same computation for each of the die roll positions $~2~$ and $~3.~$ For die roll position $~4,~$ you are enumerating U U U [2 or 3] 4 4 4, which computes to $~2 \times 6^3.$

For the set $~\{ ~\text{4 4 4 Not-4 4 4 4} ~\}, ~$ you are enumerating 4 4 4 [2 or 3] 4 4 4, which computes to $~2.$

Therefore

$$R(7) = \frac{[ ~3 \times 2 \times 6^2 \times 5 ~] + [ ~2 \times 6^3 ~] - 2}{| ~B ~|} = \frac{1510}{| ~B ~|}.$$

Therefore

$$P(7) \times R(7) = \frac{| ~B ~|}{6^7} \times \frac{1510}{| ~B ~|} = \frac{1510}{6^7}.$$


$\underline{\text{General Considerations For Inclusion-Exclusion}}$

Method-3, which is unnecessary for $~3 \leq n \leq 7,~$ will be used for all $~n \geq 8.~$ The goal is to develop an analytical method of using Inclusion-Exclusion to compute both $~P(n)~$ and $~R(n).$ To do this:

  • I will identify the set $~B,~$ which represents the set of all $~n$-length dice rolls where the first occurrence of 3 consecutive die rolls occurs specifically on die rolls $~(n-2), ~(n-1), ~$ and $~n.~$ This implies that die roll $~(n-3)~$ is specifically set to Not-4. It also implies that any $~n$-length die roll that has at least one occurrence of 3 consecutive 4's, starting anywhere within die roll positions $~1~$ through $~(n-6)~$ must be excluded from set $~B.$

  • I will (in effect) examine each $~n$-length die roll in the set $~B~$ individually, and count the total number of occurrences of either a 2 or a 3 in the individual $~n$-length die roll. So, I will enumerate the total number of occurrences of either a 2 or a 3, across all $~n$-length die rolls in the set $~B.$ Then

$$P(n) \times R(n) = \frac{| ~B ~|}{6^n} \times \frac{\text{total \# of 2's and 3's}}{| ~B ~|} = \frac{\text{total \# of 2's and 3's}}{6^n}.$$

As indicated at the start of this answer, the set $~A~$ denotes the set of all possible $~n$-length die rolls.

Let $~A'~$ denote the subset of $~A~$ where die rolls $~(n-3), ~(n-2), ~(n-1), ~$ and $~n~$ are respectively set to Not-4, 4, 4, 4. Then the set $~A'~$ is represented by the set of all $~n$-length die rolls labeled

$$\text{U U U ... U Not-4 4 4 4} ~: ~(n-4) ~\text{U's}.$$

For $~i \in \{1,2,3, \cdots, n-6\},~$ let $~A_i~$ denote the subset of $~A'~$ which contains all $~n$-length die rolls that have three consecutive 4's, starting in die roll position $~i.~$

For example,

  • $A_1~$ is represented by the set of all $~n$-length die rolls labeled
    $\displaystyle \text{4 4 4 U U U ... U Not-4 4 4 4} ~: ~(n-7) ~\text{U's}.$

  • $A_1\cap A_2~$ is represented by the set of all $~n$-length die rolls labeled
    $\displaystyle \text{4 4 4 4 U U U ... U Not-4 4 4 4} ~: ~(n-8) ~\text{U's}.$

  • $A_1\cap A_4~$ is represented by the set of all $~n$-length die rolls labeled
    $\displaystyle \text{4 4 4 4 4 4 U U ... U Not-4 4 4 4} ~: ~(n-10) ~\text{U's}.$

Let $~T_0~$ denote the total number of 2's and 3's in $~A'~$ Then

$$T_0 = 6^{n-4} \times 5 \times \left[ ~\frac{2(n-4)}{6} + \frac{2}{5} ~\right].$$

Let $~T_1~$ denote the total number of 2's and 3's in $~A_{i_1},~$ where $~1 \leq i_1 \leq (n-6).~$ That is, $~T_1~$ represents the sum of $~\displaystyle \binom{n-6}{1}~$ terms. Then, by considerations of symmetry,

$$T_1 = (n - 6) \times 6^{n-7} \times 5 \times \left[ ~\frac{2(n-7)}{6} + \frac{2}{5} ~\right].$$


Similarly, for $~r \in \{2,3,\cdots,n-6\}, ~$
let $~T_r~$ denote the total number of 2's and 3's in $~\{ ~A_{i_1} \cap A_{i_2} \cap \cdots \cap A_{i_r} ~\},~$ where $~1 \leq i_1 < i_2 < \cdots < i_r \leq (n-6).~$ That is, $~T_r~$ represents the sum of $~\displaystyle \binom{n-6}{r}~$ terms.

Considerations of symmetry will break down, when computing $~T_r,~$ for each $~r \geq 2.$ The Method-3 analysis discussed in the remainder of this answer will analytically compensate for this breakdown.

Then, for $~n \geq 8,~$ by Inclusion-Exclusion theory,

$$P(n) \times R(n) = \frac{\sum_{r = 0}^{n-6} \left[ ~(-1)^r ~T_r ~\right]}{6^n}.$$

The next three sections of this answer will :

  • Develop the helper function $~f(n,r,w,o).~$
    The variables $~n, r, w, o,~$ will be specified in the section.
  • Where appropriate, establish upper and lower bounds for the variables $~n, r, w, o.$
  • Specify a closed form formula for $~\displaystyle \sum_{n=3}^\infty P(n) \times R(n).~$

End of Part-1.

user2661923
  • 42,303
  • 3
  • 21
  • 46
0

This is Part-2 of the self-answer.

$\underline{\text{Helper Function} ~f(n,r,w,o)}$

This section will partition the $~\displaystyle \binom{n-6}{r}~$ intersections represented by the term $~T_r ~: ~r \geq 2~$ into categories. The purpose of the function $~f(n,r,w,o)~$ is to enumerate how many 2's and 3's occur in all $~n$-length die rolls that pertain to each category.

At the start of this section, for illustrative purposes, I will asssume that $~n = 20,~$ and $~r = 5.~$ Then, later in this section, I will discuss the general case of $~n \geq 8, ~r \in \{2,3,\cdots, n-6\}.$

Consider the following tableau:

i_1 - - i_2 - - i_3 - - i_4 - - i_5 - 

In the above tableau, the positions of $~i_1, \cdots, i_5,~$ are $~1, 4, 7, 10, 13,~$ respectively. This represents the intersection of the subsets $~A_{1} \cap A_4 \cap A_7 \cap A_{10} \cap A_{13},~$ which represents one of the intersections pertinent to the computation of $~T_5.$

The $~5~$ subsets involved create $~(5 +1)~$ islands between the subsets. Reading the islands from left to right, let $~x_1, \cdots, x_6,~$ denote the respective sizes of these islands. Then, you have that the ordered $~6$-tuplet $~(x_1, \cdots, x_6) = (0,2,2,2,2,1). ~$ Note that since $~5~$ of the $~(20-6)~$ die roll positions are taken by the positions of $~i_1, \cdots, i_5,~$ you must have that $~x_1 + \cdots + x_6 = (20 - 6) - 5 = 9.$

Then, the number of distinct ordered $~6$-tuplets $~(x_1,\cdots,x_6)~$ equals the number of solutions to

  • $x_1 + \cdots + x_6 = 9.$
  • $x_1, \cdots, x_6 \in \Bbb{Z_{\geq 0}}.$

By basic Stars and Bars theory, the number of solutions is
$\displaystyle \binom{9 + [6-1]}{6-1} = \binom{14}{5}.$

So, with $~n = 20, ~$ each possible intersection of $~5~$ subsets that is pertinent to the computation of $~T_5~$ is uniquely represented by one of the satisfying ordered $~6$-tuplets $~(x_1, \cdots,x_6).$

Speaking more generally, what is needed is some method of partitioning the $~\displaystyle \binom{n-6}{r} ~$ pertinent intersections into mutually exclusive categories, where each category may be analytically diagnosed.

To do this, the variables $~x_1~$ and $x_{r+1}~$ may be ignored. For the other $~(r - 1)~$ variables, I am going to let $~w~$ denote the number of such variables that are $~\geq 2~$ and let $~o~$ denote the number of such variables that are $~= 1.~$ Then, it is to be understood that exactly $~(r - 1) - w - o~$ of these variables are equal to $~0.$

So, the categories will be based on the values of the variables $~n,r,w,o.$

The helper function $~f(n,r,w,o)~$ will enumerate how many 2's and 3's occur in all $~n$-length die rolls that pertain to the category represented by the specific values of the variables $~n, ~r, ~w,~$ and $~o.~$ The following procedure will be used to compute $~f(n,r,w,o):$

  • Step 1
    Enumerate the number of possible ways that you can choose $~w~$ variables from $~x_2, \cdots, x_r,~$ and then choose $~o~$ variables from the remaining $~(r-1-w)~$ variables.

  • Step2
    Assume that (reading the variables from left to right, starting with variable $~x_2$) that the first $~w~$ variables are $~\geq 2,~$ and the next $~o~$ variables are $~= 1.~$ Then, under this assumption, identify the number of intersections that correspond to this assumption.

    The intention is that the product of the computations in Step 1 and Step 2 will deterrmine how many of the $~\displaystyle \binom{n-6}{r}~$ intersections correspond to the category represented by the specific set of values for $~n, ~r, ~w, ~$ and $~o.$

  • Step 3
    For the category represented by the specific values of the variables $~n, ~r, ~w, ~$ and $~o, ~$ consider each of the $~n$-length die rolls that pertain to this category. As will be demonstrated later in this section, each such $~n$-length die roll will have the exact same number of die roll positions in the range $~1~$ through $~(n-4)~$ inclusive, that are not forced to equal $~4~$ (i.e. that should be labeled U). Then compute $~\left[ ~6^{~~\text{number of such positions}} ~\right] \times 5.$
    This computation accommodates that die roll position $~(n-3)~$ must be specifically set to Not-4.

  • Step 4
    For the category represented by the specific values of the variables $~n, ~r, ~w, ~$ and $~o, ~$ use the analysis from Step 3 to perform the computation
    $~\displaystyle \left[ ~\frac{2}{6} \times \text{\# of die roll positions labeled U} ~\right] + \frac{2}{5}.~$
    The result is the average number of occurrences of 2's and 3's for the $~n$-length die rolls in the corresponding category. This computation also accommodates that die roll position $~(n-3)~$ must be specifically set to Not-4.

  • Step 5
    Take the combined product of the computations in each of Steps 1 through 4. The result will be the function $~f(n,r,w,o).$

The Step 1 computation is:

$$\binom{r-1}{w} \times \binom{r-1-w}{o}.$$

The analysis for the Step 2 computation requires discussion. In the basic Stars and Bars enumeration, you start with $~(r + 1)~$ variables, whose sum is $~(n-6 - r).~$ Eliminating the $~(r - 1 - w - o) ~$ variables that are $~= 0~$ reduces the number of variables to $~(2 + w + o),~$ and leaves the sum of $~(n - 6 - r)~$ unchanged.

Then, eliminating the $~o~$ variables that are $~= 1~$ reduces the number of variables to $~(w + 2),~$ and reduces the sum to $~(n - 6 - r - o).$ So, at this point, the Step 2 computation is represented by the number of solutions to

  • $x_1 + y_2 + \cdots + y_{w+1} + x_{r+1} = (n - 6 - r - o).$
  • $x_1, x_{r+1} \in \Bbb{Z_{\geq 0}}.$
  • $y_2, \cdots, y_{w+1} \in \Bbb{Z_{\geq 2}}.$

Now employ the further change of variables $~z_i = y_i - 2 ~: ~i \in \{2,3,\cdots,w+1\}.$
This leaves the number of variables unchanged at $~(w + 2)~$ and reduces the sum to $~(n - 6 - r - 2w - o).$ Therefore, the Step 2 computation is represented by the number of solutions to

  • $x_1 + z_2 + \cdots + z_{w+1} + x_{r+1} = (n - 6 - r - 2w - o).$
  • $x_1, x_{r+1} \in \Bbb{Z_{\geq 0}}.$
  • $z_2, \cdots, z_{w+1} \in \Bbb{Z_{\geq 0}}.$

By basic Stars and Bars theory, the Step 2 computation is therefore

$$\displaystyle \binom{[n - 6 - r - 2w - o] + [w + 1]}{w + 1} = \binom{n-5 - r - w - o}{w+1}.$$

The analysis for the Step 3 computation also requires discussion. First, suppose that $~w = (r-1),~$ which implies that $~o = 0, ~(r - 1 - w - o) = 0. ~$ Then, each pair of subsets $~S_i~$ and $~S_{i+1},~$ has at least two die roll positions between them. Therefore, you can regard this pair of subsets as fully uncompressed. Then, of the $~n - 4~$ die roll positions that precede die roll positions $~(n-3)~$ through $~n,~$ exactly $~(3r)~$ of them are forced to equal $~4.~$

Now, assume instead that there are $~o~$ of the $~(r - 1) ~$ variables that are $~= 1.~$ Then, you have $~o~$ partially compressed pairs of subsets that (together) use $~5~$ die roll positions instead of $~6~$ die roll positions. This implies that you now have $~(3r - o)~$ die roll positions that are forced to equal $~4.~$

Now, further assume that you have some fully compressed pairs of subsets because $~(r - 1 - w - o) \neq 0.~$ Similar to the analysis in the previous paragraph, this implies that exactly $~[ ~(3r - o) - 2(r - 1 - w - o) ~] = [ ~r + 2 + 2w + o ~] ~$ of the die roll positions are forced to equal $~4.~$

So, with respect to the first $~n-4~$ die roll positions, you have exactly

  • $[ ~r + 2 + 2w + o ~]~$die roll positions that will be labeled 4.

  • $[ ~n-4 ~] - [ ~r + 2 + 2w + o ~] = [ ~n - 6 - r - 2w - o ~]~$ die roll positions that will be labeled U.

Therefore, the computation for Step 3 is

$$6^{ ~[n - 6 - r - 2w - o] ~} \times 5.$$

Using the Step 3 analysis above, the computation for Step 4 is

$$ \left[ ~\frac{2}{6} \times ( ~n - 6 - r - 2w - o ~) ~\right] + \frac{2}{5}.$$

Therefore, by Step 5,

$$f(n,r,w,o) = \binom{r-1}{w} \times \binom{r-1-w}{o} \times \binom{n-5 - r - w - o}{w+1}$$

$$ \times ~6^{ ~[n - 6 - r - 2w - o] ~} \times 5 \times \left\{ ~\left[ ~\frac{2}{6} \times ( ~n - 6 - r - 2w - o ~) ~\right] + \frac{2}{5} ~\right\}.$$

The next section in this answer will specify the allowable ranges for each of the variables $~n, ~r, ~w,~$ and $~o.$

So, by the analysis in this section, for this specific value of $~n~$ and $~r,~$

$$T_r = \sum_{w ~\text{in range}} \left\{ \sum_{o ~\text{in range}} ~[ ~f(n,r,w,o ~] \right\}.$$


$\underline{\text{Lower And Upper Bounds For} ~n, ~r, ~w, ~\text{And} ~o}$

You have that

  • $\displaystyle f(n,r,w,o) = \binom{r-1}{w} \times \binom{r-1-w}{o} \times \binom{n-5 - r - w - o}{w+1}$

    $\displaystyle \times ~6^{ ~[n - 6 - r - 2w - o] ~} \times 5 \times \left\{ ~\left[ ~\frac{2}{6} \times ( ~n - 6 - r - 2w - o ~) ~\right] + \frac{2}{5} ~\right\}.$

  • $n \in \Bbb{Z_{\geq 8}}.$

  • With respect to the appropriate range of $~r,~$ so that $~f(n,r,w,o)~$ may be applied, the lower bound for $~r~$ is $~2 \leq r.$

My experience with math problems of this nature has taught me that the easiest way to compute the upper bound for $~r,~$ and the lower/upper bounds for $~w~$ and $~o,~$ is to consider that for any pertinent expression of the form $~\displaystyle \binom{p}{q} ~: ~p,q \in \Bbb{Z},~$ you must have $~q \geq 0, ~p \geq q. ~$ Further, the expression $~[~n - 6 - r - 2w - o ~] ~$ must be a non-negative integer.

Therefore, the first take on the bounding constraints is that

  • $0 \leq w \leq r-1.$
  • $0 \leq o \leq r-1-w.$
  • $n - 6 - r - 2w - o \geq 0.$

The upper bound for $~r~$ is achieved when $~0 = w,o.$ So, the range of $~r~$ is

$$r \in \Bbb{Z}, ~2 \leq r \leq n-6.$$

Both of the variables $~w~$ and $~o~$ can be as small as $~0,~$ since this merely represents having the intersection $~\{ ~S_{i_1} \cap S_{i_2} \cap \cdots \cap S_{i_r} ~\}~$ fully compressed.

The upper bound for $~w~$ may be determined by setting $~o = 0.~$

Therefore, the range of $~w~$ is

$$w \in \Bbb{Z}, ~0 \leq w \leq \min\left\{ ~r-1, ~\left\lfloor ~\frac{n-6-r}{2} ~\right\rfloor ~\right\}.$$

Similarly, the range of $~o~$ is

$$o \in \Bbb{Z}, ~0 \leq o \leq \min\left\{ ~r-1-w, ~n - 6 - r - 2w ~\right\}.$$


$\underline{\text{Closed Form Formula For The Problem}}$

The desired computation is

$$\sum_{n=3}^\infty [ ~P(n) \times R(n) ~],$$

if the above infinite series is convergent rather than divergent.

For $~n \in \Bbb{Z}, ~3 \leq n \leq 7,~$ manual computation gives:

  • $P(3) \times R(3) = 0.$

  • $P(4) \times R(4) = \dfrac{2}{6^4}.$

  • $P(5) \times R(5) = \dfrac{22}{6^5}.$

  • $P(6) \times R(6) = \dfrac{192}{6^6}.$

  • $P(7) \times R(7) = \dfrac{1510}{6^7}.$

The remainder of this section assumes that $~n~$ is some fixed value in $~\Bbb{Z_{\geq 8}}.$

$$T_0 = 6^{n-4} \times 5 \times \left[ ~\dfrac{2(n-4)}{6} + \dfrac{2}{5} ~\right].$$

$$T_1 = (n - 6) \times 6^{n-7} \times 5 \times \left[ ~\frac{2(n-7)}{6} + \frac{2}{5} ~\right].$$

The remainder of this section assumes that $~r \in \Bbb{Z}, ~2 \leq r \leq n-6.$

The helper function $~f(n,r,w,o)~$is defined as

$$f(n,r,w,o) = \binom{r-1}{w} \times \binom{r-1-w}{o} \times \binom{n-5 - r - w - o}{w+1}$$

$$ \times ~6^{ ~[n - 6 - r - 2w - o] ~} \times 5 \times \left\{ ~\left[ ~\frac{2}{6} \times ( ~n - 6 - r - 2w - o ~) ~\right] + \frac{2}{5} ~\right\}.$$

The ranges for the variables $~w~$ and $~o~$ are

$$w \in \Bbb{Z}, ~0 \leq w \leq \min\left\{ ~r-1, ~\left\lfloor ~\frac{n-6-r}{2} ~\right\rfloor ~\right\}.$$

$$o \in \Bbb{Z}, ~0 \leq o \leq \min\left\{ ~r-1-w, ~n - 6 - r - 2w ~\right\}.$$

Then

$$T_r = \sum_{w ~\text{in range}} \left\{ \sum_{o ~\text{in range}} ~[ ~f(n,r,w,o ~] \right\}.$$

and

$$P(n) \times R(n) = \frac{\sum_{r = 0}^{n-6} \left[ ~(-1)^r ~T_r ~\right]}{6^n}.$$


$\underline{\text{Sanity Checking - Method-3 Results}}$

For $~4 \leq n \leq 7,~$ I copy-pasted the manual computations into the table below.
For $~n \geq 8, ~$ I wrote a computer program to implement the formulas in the previous section. For what it's worth, I also wrote a second computer program to verify the results for $~7 \leq n \leq 13.$

In the table below, the second column is rounded to 5 decimal places and the third column is the total number of occurrences of 2's and 3's, for all $~n$-length die rolls that satisfy event $~E(n).~$ If an exact value was given for the second column, then you would have that

$$\text{second column} ~\times 6^n = ~\text{third column}.$$

For $~4 \leq n \leq 30,~$ the results show that the expression $~[ ~P(n) \times R(n) ~]~$ is strictly increasing. If it can be proven that this trend continues as $~n \to \infty,~$ then this will prove that $~\displaystyle \sum_{n=3}^\infty [ ~P(n) \times R(n) ~] ~$ is divergent.

$$\begin{array}{| r | r | r |} \hline n & P(n) \times R(n) & \sum_{r=0}^{n-6} (-1)^r T_r \\ \hline 4 & 0.00154 & 2 \\ \hline 5 & 0.00283 & 22 \\ \hline 6 & 0.00412 & 192 \\ \hline 7 & 0.00539 & 1510 \\ \hline 8 & 0.00666 & 11190 \\ \hline 9 & 0.00792 & 79820 \\ \hline 10 & 0.00917 & 554400 \\ \hline 11 & 0.01041 & 3775700 \\ \hline 12 & 0.01164 & 25328650 \\ \hline 13 & 0.01285 & 167891250 \\ \hline 14 & 0.01406 & 1102104000 \\ \hline 15 & 0.01526 & 7176632250 \\ \hline 16 & 0.01645 & 46416818750 \\ \hline 17 & 0.01763 & 298481875000 \\ \hline 18 & 0.01880 & 1909815600000 \\ \hline 19 & 0.01997 & 12166705225000 \\ \hline 20 & 0.02112 & 77212897631250 \\ \hline 21 & 0.02226 & 488349376568750 \\ \hline 22 & 0.02340 & 3079311408000000 \\ \hline 23 & 0.02452 & 19363901807468750 \\ \hline 24 & 0.02563 & 121468323918343750 \\ \hline 25 & 0.02674 & 760261239996562500 \\ \hline 26 & 0.02784 & 4748735322022500000 \\ \hline 27 & 0.02893 & 29606234723168437500 \\ \hline 28 & 0.03001 & 184265565632035156250 \\ \hline 29 & 0.03108 & 1145035615851078906250 \\ \hline 30 & 0.03214 & 7104918365854050000000 \\ \hline \end{array}$$


$\underline{\text{Sanity Checking - Method-1 : Recursion Analysis}}$

Throughout this section, the discussion is focusing on $~n$-length die rolls where event $~E(n)~$ has occurred. This implies that the $~n$-length die rolls must end with Not-4 4 4 4. So, to facilitate using recursion here, I am focusing on adding a die roll to the beginning of the $~n$-length die roll, rather than the end of the $~n$-length die roll.

Let $~g(n,0)~$ denote the # of $~n$-length die rolls that start with Not-4.
Let $~g(n,1)~$ denote the # of $~n$-length die rolls that start with 4 Not-4.
Let $~g(n,2)~$ denote the # of $~n$-length die rolls that start with 4 4 Not-4.
Let $~g(n)~$ denote the total # of $~n$-length die rolls.

Let $~h(n,0)~$ denote the # of occurrences of 2's or 3's in all $~n$-length die rolls that start with Not-4.
Let $~h(n,1)~$ denote the # of occurrences of 2's or 3's in all $~n$-length die rolls that start with 4 Not-4.
Let $~g(n,2)~$ denote the # of occurrences of 2's or 3's in all $~n$-length die rolls that start with 4 4 Not-4.
Let $~h(n)~$ denote the # of occurrences of 2's or 3's in any $~n$-length die rolls.

Then, you have the following recursion formulas:

  • $g(n+1,0) = 5 \times g(n).$
    That is, you have $~5~$ die roll choices that can be appended to the beginning of any $~n$-length die roll.

  • $g(n+1,1) = g(n,0).$
    You must start with an $~n$-length die roll that begins Not-4, and then append 4 to the beginning of the $~n$-length die roll.

  • $g(n+1,2) = g(n,1).$
    You must start with an $~n$-length die roll that begins 4 Not-4, and then append 4 to the beginning of the $~n$-length die roll.

  • $g(n) = g(n,0) + g(n,1) + g(n,2).$

  • $h(n+1,0) = [ ~5 \times h(n) ~] + [ ~2 \times g(n) ~].$
    This is tricky.
    Because the die roll appended to the start of the $~n$-length die roll is Not-4, the number of resulting $~(n+1)$-length die rolls is $~5~$ times the number of $~n$-length die rolls. Therefore, focusing only on the original $~n$-length die roll, you are increasing the # of 2's and 3's by a factor of $~5. ~$ This explains the $~[ ~5 \times h(n) ~]~$ computation.

    Further, when counting the # of 2's and 3's that occur in the appended die roll position, you start with $~g(n)~$ $~n$-length die rolls, and you have two die roll choices to append to any of these die rolls.This explains the $~[ ~2 \times g(n) ~] ~$ computation.

  • $h(n+1,1) = h(n,0).$
    Since you are appending a 4 to the start of the $~n$-length die roll, the number of $~(n+1)$-length die rolls will equal the number of $~n$-length die rolls. Further, (again) since you are appending a 4 to the start of the $~n$-length die roll, there are no occurrences of 2's or 3's in the appended die roll.

  • $h(n+1,2) = h(n,1).$
    The exact same analysis in the previous bullet point also applies here.

  • $h(n) = h(n,0) + h(n,1) + h(n,2).$


$\underline{\text{Sanity Checking - Method-1 : Recursion Results}}$

The two tables below were generated by manually computing the $~n=4~$ entries, and then using the formulas from the previous section to compute the values from $~n = 5~$ through $~n = 30.~$ For the second table below, I have (in effect) omitted the $~\dfrac{1}{6^n} ~$ denominator from the $~[ ~P(n) \times R(n) ~]~$ computation. So, the $~h(n)~$ column represents the total number of occurrences of 2's and 3's in all $~n$-length die rolls where event $~E(n)~$ has occurred. You can see that the Method-1 results match the Method-3 results.

Assuming that $~\displaystyle \sum_{n=3}^\infty [ ~P(n) \times R(n)~] ~$ is divergent, one way of proving this would be to use the formulas in the previous section to demonstrate that for all $~n \in \Bbb{Z_{\geq 4}},~$ that $~\dfrac{h(n+1)}{h(n)} > 6.~$ While this type of analysis is beyond my abilities, it seems that it would be easier to demonstrate than trying to demonstrate the analogous result from Method-3. That is, the Method-3 formulas seem too convoluted to analyze in this manner.

$$\begin{array}{| r | r | r | r | r |} \hline n & g(n,0) & g(n,1) & g(n,2) & g(n) \\ \hline 4 & 5 & 0 & 0 & 5 \\ \hline 5 & 25 & 5 & 0 & 30 \\ \hline 6 & 150 & 25 & 5 & 180 \\ \hline 7 & 900 & 150 & 25 & 1075 \\ \hline 8 & 5375 & 900 & 150 & 6425 \\ \hline 9 & 32125 & 5375 & 900 & 38400 \\ \hline 10 & 192000 & 32125 & 5375 & 229500 \\ \hline 11 & 1147500 & 192000 & 32125 & 1371625 \\ \hline 12 & 6858125 & 1147500 & 192000 & 8197625 \\ \hline 13 & 40988125 & 6858125 & 1147500 & 48993750 \\ \hline 14 & 244968750 & 40988125 & 6858125 & 292815000 \\ \hline 15 & 1464075000 & 244968750 & 40988125 & 1750031875 \\ \hline 16 & 8750159375 & 1464075000 & 244968750 & 10459203125 \\ \hline 17 & 52296015625 & 8750159375 & 1464075000 & 62510250000 \\ \hline 18 & 312551250000 & 52296015625 & 8750159375 & 373597425000 \\ \hline 19 & 1867987125000 & 312551250000 & 52296015625 & 2232834390625 \\ \hline 20 & 11164171953125 & 1867987125000 & 312551250000 & 13344710328125 \\ \hline 21 & 66723551640625 & 11164171953125 & 1867987125000 & 79755710718750 \\ \hline 22 & 398778553593750 & 66723551640625 & 11164171953125 & 476666277187500 \\ \hline 23 & 2383331385937500 & 398778553593750 & 66723551640625 & 2848833491171875 \\ \hline 24 & 14244167455859375 & 2383331385937500 & 398778553593750 & 17026277395390625 \\ \hline 25 & 85131386976953125 & 14244167455859375 & 2383331385937500 & 101758885818750000 \\ \hline 26 & 508794429093750000 & 85131386976953125 & 14244167455859375 & 608169983526562500 \\ \hline 27 & 3040849917632812500 & 508794429093750000 & 85131386976953125 & 3634775733703515625 \\ \hline 28 & 18173878668517578125 & 3040849917632812500 & 508794429093750000 & 21723523015244140625 \\ \hline 29 & 108617615076220703125 & 18173878668517578125 & 3040849917632812500 & 129832343662371093750 \\ \hline 30 & 649161718311855468750 & 108617615076220703125 & 18173878668517578125 & 775953212056593750000 \\ \hline \end{array}$$

$$\begin{array}{| r | r | r | r | r |} \hline n & h(n,0) & h(n,1) & h(n,2) & h(n) \\ \hline 4 & 2 & 0 & 0 & 2 \\ \hline 5 & 20 & 2 & 0 & 22 \\ \hline 6 & 170 & 20 & 2 & 192 \\ \hline 7 & 1320 & 170 & 20 & 1510 \\ \hline 8 & 9700 & 1320 & 170 & 11190 \\ \hline 9 & 68800 & 9700 & 1320 & 79820 \\ \hline 10 & 475900 & 68800 & 9700 & 554400 \\ \hline 11 & 3231000 & 475900 & 68800 & 3775700 \\ \hline 12 & 21621750 & 3231000 & 475900 & 25328650 \\ \hline 13 & 143038500 & 21621750 & 3231000 & 167891250 \\ \hline 14 & 937443750 & 143038500 & 21621750 & 1102104000 \\ \hline 15 & 6096150000 & 937443750 & 143038500 & 7176632250 \\ \hline 16 & 39383225000 & 6096150000 & 937443750 & 46416818750 \\ \hline 17 & 253002500000 & 39383225000 & 6096150000 & 298481875000 \\ \hline 18 & 1617429875000 & 253002500000 & 39383225000 & 1909815600000 \\ \hline 19 & 10296272850000 & 1617429875000 & 253002500000 & 12166705225000 \\ \hline 20 & 65299194906250 & 10296272850000 & 1617429875000 & 77212897631250 \\ \hline 21 & 412753908812500 & 65299194906250 & 10296272850000 & 488349376568750 \\ \hline 22 & 2601258304281250 & 412753908812500 & 65299194906250 & 3079311408000000 \\ \hline 23 & 16349889594375000 & 2601258304281250 & 412753908812500 & 19363901807468750 \\ \hline 24 & 102517176019687500 & 16349889594375000 & 2601258304281250 & 121468323918343750 \\ \hline 25 & 641394174382500000 & 102517176019687500 & 16349889594375000 & 760261239996562500 \\ \hline 26 & 4004823971620312500 & 641394174382500000 & 102517176019687500 & 4748735322022500000 \\ \hline 27 & 24960016577165625000 & 4004823971620312500 & 641394174382500000 & 29606234723168437500 \\ \hline 28 & 155300725083249218750 & 24960016577165625000 & 4004823971620312500 & 184265565632035156250 \\ \hline 29 & 964774874190664062500 & 155300725083249218750 & 24960016577165625000 & 1145035615851078906250 \\ \hline 30 & 5984842766580136718750 & 964774874190664062500 & 155300725083249218750 & 7104918365854050000000 \\ \hline \end{array}$$


$\underline{\text{Sanity Checking - Method-2 : Probability-Oriented Recursion Analysis}}$

In this section, it is being assumed that no occurrence of $~3~$ consecutive 4's has yet occurred. So, there are three possible situations to consider.

  • Situation $~S_0.$
    The last die roll was Not-4.
    Included in $~S_0~$ is the situation where no die rolls have yet been made.

  • Situation $~S_1.$
    The last two die rolls were Not-4 4.
    Included in $~S_1~$ is the situation where there has been exactly 1 die roll, where this die roll was a 4.

  • Situation $~S_2.$
    The last three die rolls were Not-4 4 4.
    Included in $~S_2~$ is the situation where there have been exactly 2 die rolls, where these die rolls were 4 4.

For $~k \in \{0,1,2\},~$ let $~J_k~$ represent the total number of 2's and 3's that are expected to occur, from this point forward, assuming that you are currently in situation $~S_k. ~$ So, it is desired to compute $~J_0.$ Then:

$$J_0 = \left[ ~\frac{1}{6} ~J_1 ~\right] + \left[ ~\frac{2}{6} ~\left(1 + J_0 ~\right) ~\right] + \left[ ~\frac{3}{6} ~J_0 ~\right] \implies J_0 = J_1 + 2.$$

$$J_1 = \left[ ~\frac{1}{6} ~J_2 ~\right] + \left[ ~\frac{2}{6} ~\left(1 + J_0 ~\right) ~\right] + \left[ ~\frac{3}{6} ~J_0 ~\right] \implies $$

$$J_0 - 2 = J_1 = \frac{1}{6} \left[ ~(5J_0) + 2 + J_2 ~\right] \implies 6J_0 - 12 = (5J_0) + 2 + J_2 \implies J_0 = J_2 + 14.$$

$$J_2 = \left[ ~\frac{1}{6} \times 0 ~\right] + \left[ ~\frac{2}{6} ~\left(1 + J_0 ~\right) ~\right] + \left[ ~\frac{3}{6} ~J_0 ~\right] \implies $$

$$J_0 - 14 = J_2 = \frac{1}{6} \left[ ~(5J_0) + 2 ~\right] \implies 6J_0 - 84 = (5J_0) + 2 \implies J_0 = 86.$$

Here, I see two possibilities:

  • Either I have made some analytical mistake in this section,
  • or, contrary to the guesswork that I made in the previous sanity checking sections, $~\displaystyle \sum_{n=3}^\infty [ ~P(n) \times R(n) ~] ~$ is a convergent series whose limit is exactly $~86.$

$\underline{\text{Sanity Checking - Method-3 Defects}}$

I see three defects in the (Method-3) Inclusion-Exclusion approach:

  • With the alternative problem of computing the exact value of $~[ ~P(n) \times R(n) ~], ~$ for a specific value of $~n,~$ if $~n~$ is reasonably small then Method-1 recursion is much easier. However, if (for example) $~n > 100,~$ then Method-3 is probably easier.

  • To obtain a final answer to the problem, you need to compute

    $\displaystyle \sum_{n=3}^\infty \left[ ~P(n) \times R(n) ~\right].$

    This requires that the limit, as $~n \to \infty,~$ be computed for the infinite series. Unfortunately, the convolutions in the Method-3 closed form formulas are too extreme for me to attempt to determine whether the infinite series is convergent or divergent, let alone try to compute the limit of the infinite series.

  • Similarly, the convolutions in the Method-3 closed form formulas are also too extreme for me to attempt to analytically prove the equivalence between the general Method-3 computation of $~[ ~P(n) \times R(n) ~]~$ and the corresponding computations from either Method-1 or Method-2.

    Instead, I wrote a computer program to compute the Method-3 generated computations of $~[ ~P(n) \times R(n) ~] ~$ for each $~n \in \{8,9,10,\cdots,30\}.~$ The results matched the Method-1 results, and simultaneously suggested a trend that was apparently contradicted by my Method-2 analysis.

user2661923
  • 42,303
  • 3
  • 21
  • 46
0

I have ran the following code to double-check your work by simulating the process

import numpy as np

counts = []

n = 100000 for _ in range(n): sequence = np.random.randint(1,7, size=(10000,)) count = 0 for idx in range(len(sequence)): if sequence[idx] == 4 and sequence[idx+1] == 4 and sequence[idx+2] == 4: break count += (sequence[idx] == 2 ) + (sequence[idx] == 3) counts.append(count)

print(np.mean(counts), np.std(counts) / n**0.5)

I got: 86.2942 0.8620524836899434 for n = 10,000 and 85.73485 0.27271136289999903 with n = 100,000

Your answer of E(count) = 86 sounds correct, even though my calculation isn't super precise.

It would be fairly trivial to improve the sampling algorithm:

  • when you generate a sequence, generate it only up to the triple-fours
  • compute the expected number of 2-3 if all the non-4 were redrawn; that's $count(V \neq 4) * 2 / 5$
  • compute the empirical averages of those expected numbers

Actually, now that I've written this, this also gives a decent path towards computing the value, if you want to try.

  • Please see the "Sanity Checking - Method-2 : Probability-Oriented Recursion Analysis" section, near the end of the Part-2 answer, where I compute an answer of exactly 86. In your opinion, is the analysis in that section valid? – user2661923 Jun 29 '24 at 22:32
  • I have always hated discrete probabilities, sorry ^_^ I'm brave enough to do a monte carlo simulation, but not check some proof. But as I highlighted, counting the number of non-fours before the ending point then multiplying by 2/5 should give the answer, I think? – Guillaume Dehaene Jun 29 '24 at 22:44
0

$\def\ed{\stackrel{\text{def}}{=}}$ You can model this process as a mathematical structure known as a Markov chain, with $5$ states:

  • State $1$, in which you've just thrown a $2$ or $3$;
  • State $2$, in which you've just rolled $1,5$ or $6$;
  • State $3$, in which you've just rolled a $4$ not immediately preceded by another $4$;
  • State $4$, in which you've just rolled two successive $4$s not immediately preceded by another $4$;
  • State $5$, in which you've just rolled three successive $4$s, thus terminating the process.

At any time during the process, it will be in one of these states, and the answer you're looking for is the expected number or times the process visits state $1$ before it reaches state $5$. This is a problem whose answer can be obtained by a well-known standard procedure.

The behaviour of a Markov chain is completely determined by its transition matrix and its initial state distribution. In your case, the chain will be in state $1$ with probability $\ \frac{1}{3}\ ,$ state $2$ with probability $\ \frac{1}{2}\ ,$ or state $3$ with probability $\ \frac{1}{6}\ $ immediately after your first throw. Thus, the initial state distribution is given by the probability row-vector $$ \pi_1^T=\pmatrix{\frac{1}{3}&\frac{1}{2}&\frac{1}{6}&0&0}\ . $$ If the state of the process after the $\ t^\text{th}\ $ throw is $\ X_t\ ,$ then the independence of successive throws of the die guarantees that the conditional distribution of the state at any time, given the values of all the preceding states satisfies the Markov property: $$ \mathbb{P}\big(X_t\in A\,\big|\,X_{t-1}=x_{t-1},X_{t-2}=x_{t-2},\dots,X_1=x_1\big)=\mathbb{P}\big(X_t\in A\,\big|\,X_{t-1}=x_{t-1}\big)\ , $$ and the transition matrix $\ P\ $ of the process is the $\ 5\times5\ $ stochastic matrix whose entry in row $\ i\ $ and column $\ j\ $ is $$ p_{ij}\ed\mathbb{P}\big(X_t=j\,\big|\,X_{t-1}=i\big) $$ (independent of $\ t\ $). The distribution $\ \pi_t\ $ of the state after $\ t\ $ throws of the die is then given by $$ \pi_t^T=\pi_1^TP^{t-1}\ .\tag{1}\label{e1} $$ Filling in the entries of $\ P\ $ for your process gives $$ P=\pmatrix{\frac{1}{3}&\frac{1}{2}&\frac{1}{6}&0&0\\ \frac{1}{3}&\frac{1}{2}&\frac{1}{6}&0&0\\\frac{1}{3}&\frac{1}{2}&0&\frac{1}{6}&0\\\frac{1}{3}&\frac{1}{2}&0&0&\frac{1}{6}\\0&0&0&0&1}\ , $$ and it follows from equation \eqref{e1} that the probability that the process is in state $\ i\ $ after $\ t\ $ throws of the die is given by $$ \mathbb{P}\big(X_t=i\big)=\pi_1^TP^{t-1}e_i\ ,\tag{2}\label{e2} $$ where $\ e_i\ $ is the unit column vector whose $\ i^\text{th}\ $ entry is $1$ and all of whose other entries are zero. If now $$ F_t\ed\cases{1&if $\ X_t=1\ $\\ 0&otherwise}\ , $$ then the total number of times the process visits state $1$ (i.e. the total number of times a $2$ or $3$ is thrown) until the process terminates is $$ \sum_{t=1}^\infty F_t $$ and the expected value of this is \begin{align} \mathbb{E}\left(\sum_{t=1}^\infty F_t\right)&=\sum_{t=1}^\infty\mathbb{E}\big(F_t\big)\\ &=\sum_{t=1}^\infty\mathbb{P}\big(X_t=1\big)\\ &=\sum_{t=1}^\infty \pi_1^TP^{t-1}e_1\hspace{2em}\text{(from equation \eqref{e2})}\ ,\\ &=\sum_{i=1}^5\pi_1^Te_i\sum_{t=1}^\infty e_i^TP^{t-1}e_1\hspace{1em}\left(\text{because}\ \sum_{i=1}^5 e_ie_i^T=I_{5\times5}\right)\ . \end{align} Now \begin{align} \sum_{t=1}^\infty e_i^TP^{t-1}e_1&=e_i^Te_1+\sum_{t=2}^\infty e_i^TP^{t-1}e_1\\ &=e_i^Te_1+\sum_{t=2}^\infty e_i^TPP^{t-2}e_1\\ &=e_i^Te_1+e_i^T\sum_{j=1}^5Pe_j\sum_{t=2}^\infty e_j^TP^{t-2}e_1\\ &=e_i^Te_1+e_i^T\sum_{j=1}^5Pe_j\sum_{t=1}^\infty e_j^TP^{t-1}e_1\ ,\tag{3}\label{e3} \end{align}
and if we put $\ g_i\ed\sum_\limits{t=1}^\infty e_i^TP^{t-1}e_1\ ,$ then $\ g_5=0\ $ (because $\ e_5^TP^t=e_5^T\ $ for all $\ t\ $), and therefore the equations \eqref{e3} constitute $4$ linear equations for the $4$ quantities $\ g_1,g_2,\dots,g_4\ ,$ which we can write in matrix form as $$ (I_{4\times4}-P_{4\times4})\pmatrix{g_1\\g_2\\g_3\\g_4}=\pmatrix{1\\0\\0\\0}\ ,\tag{4}\label{e4} $$ where $\ P_{4\times4}\ $ is the $\ 4\times4\ $ matrix comprising the first $4$ rows and columns of $\ P\ .$ Thus we get \begin{align} \pmatrix{g_1\\g_2\\g_3\\g_4}&=(I_{4\times4}-P_{4\times4})^{-1}\pmatrix{1\\0\\0\\0}\\ &=\pmatrix{87&129&36&6\\ 86&130&36&6\\ 84&126&36&6\\ 72&108&30&6}\pmatrix{1\\0\\0\\0}\\ &=\pmatrix{87\\86\\84\\72}\ , \end{align} and the expression for $\ \mathbb{E}\left(\sum_\limits{t=1}^\infty F_t\right)\ $ above becomes \begin{align} \mathbb{E}\left(\sum_{t=1}^\infty F_t\right)&=\sum_{i=1}^4\pi_1^Te_ig_i\\ &=\frac{87}{3}+\frac{86}{2}+\frac{84}{6}\\ &=86\ . \end{align} In practice, once you're familiar with the procedure for solving problems like this, most of the above rigmarole for deriving the result would be unnecessary. The quantities $\ g_i\ $ are the expected current and future number of times the process is visiting or will visit state $1$ given that it is currently in state $\ i\ .$ Once you're familiar with the procedure, you'd recognise immediately that the quantity you're looking for is $\ \pi_1^T\pmatrix{g_1\\g_2\\g_3\\g_4}\ ,$ where $\ \pmatrix{g_1\\g_2\\g_3\\g_4}\ $ is the solution to equation \eqref{e4}.

  • Given my lack of formal education in probability theory, I would have to self-study a corresponding math book for some time before I could attain confidence in your analysis. Also, your answer begs the question: is the specific analysis given in my "Sanity Checking - Method-2 : Probability-Oriented Recursion Analysis" section, by itself, valid? – user2661923 Jul 02 '24 at 15:30