Calculating these probabilities is fairly straightforward if you know some theory of generating functions. Here’s how it works.
Let x be a variable representing the probability of a single 6, and let y represent the probability of “even but not 6”. A single string consisting of even numbers can be written like, say, xyxxy, and this expression (which simplifies to x3y2) is the same as the probability of the string. Now let’s find the generating function for all strings you can get in (A). These strings are generated by the following unambiguous regular expression:
y∗(xyy∗)∗xx
The magical property of generating functions is that if you have an unambiguous regular expression, the corresponding generating function is easy to calculate: concatenation becomes product, union becomes sum, and star becomes the function z→1/(1−z). Using this, the generating function for the strings in (A) is
fA(x,y)=x21−y−xy.
Similarly, the strings possible in (B) have unambiguous regular expression y∗xy∗x and generating function fB(x,y)=x2(1−y)2.
If you plug in the probabilities x=1/6,y=1/3, the above functions will give you the probability of a string in (A) occurring and of a string in (B) occurring, respectively. But that’s not what we want; we want conditional expectations. To get that, we need the probability of each string to be weighted by its length (then to divide by the overall probability). The length of a string is the number of x and y variables in it—its degree. So we can get the sum of lengths-times-probabilities by scaling x and y by t, taking a derivative with respect to t, and plugging in t=1. Then we divide by the overall probabilities. So the conditional expectations are
^fA(x,y)=ddtfA(tx,ty)|t=1fA(x,y)=2−y1−y−xy,
^fB(x,y)=ddtfB(tx,ty)|t=1fB(x,y)=21−y.
Now just plug in x=1/6,y=1/3 to get the conditional expectations.
Calculating these probabilities is fairly straightforward if you know some theory of generating functions. Here’s how it works.
Let x be a variable representing the probability of a single 6, and let y represent the probability of “even but not 6”. A single string consisting of even numbers can be written like, say, xyxxy, and this expression (which simplifies to x3y2) is the same as the probability of the string. Now let’s find the generating function for all strings you can get in (A). These strings are generated by the following unambiguous regular expression:
y∗(xyy∗)∗xx
The magical property of generating functions is that if you have an unambiguous regular expression, the corresponding generating function is easy to calculate: concatenation becomes product, union becomes sum, and star becomes the function z→1/(1−z). Using this, the generating function for the strings in (A) is
fA(x,y)=x21−y−xy.
Similarly, the strings possible in (B) have unambiguous regular expression y∗xy∗x and generating function fB(x,y)=x2(1−y)2.
If you plug in the probabilities x=1/6,y=1/3, the above functions will give you the probability of a string in (A) occurring and of a string in (B) occurring, respectively. But that’s not what we want; we want conditional expectations. To get that, we need the probability of each string to be weighted by its length (then to divide by the overall probability). The length of a string is the number of x and y variables in it—its degree. So we can get the sum of lengths-times-probabilities by scaling x and y by t, taking a derivative with respect to t, and plugging in t=1. Then we divide by the overall probabilities. So the conditional expectations are
^fA(x,y)=ddtfA(tx,ty)|t=1fA(x,y)=2−y1−y−xy,
^fB(x,y)=ddtfB(tx,ty)|t=1fB(x,y)=21−y.
Now just plug in x=1/6,y=1/3 to get the conditional expectations.