# Homework Help: Probability of 2 sevens before 6 evens

1. Dec 3, 2012

### CAF123

1. The problem statement, all variables and given/known data
In successive rolls of a pair of fair die, what is the probability of getting 2 sevens before 6 even numbers?

3. The attempt at a solution
So, I read this once and then twice and then a third time. You can't get a seven on a fair die (assuming the die is six sided)? I proceeded on the assumption the question means the sum of the two die is seven and sum of two die is even
Let E be the event of rolling seven: E = {(1,6),(2,5),(3,4)} => P(E) = 3/21 = 1/7.
I believe the size of the sample space, |s| = 21, since we don't want to distinguish between, say, (1,6) and (6,1).
Let F be the event that you get 6 even numbers: F = {(1,1),(1,3),(1,5),(2,2),(2,4),(2,6),(3,3),(3,5),(4,4),(4,6),(5,5),(6,6)} => P(F) = 12/21.

Given that the number of rolls can be infinite, P(2 sevens) = 1 and P(6 even numbers) = 1, since there is no limit on the number of rolls and if something can happen, it will happen. Using the eqn P(2 sevens before 6 evens) = P(2 sevens)/(P(2 sevens) + P(6 evens)) gives an answer of 1/2, which is close to the actual answer. Why does this not work?

Also, I am aware the above is quite a 'mechanical' way of doing this question. I tried it using summations with the probabilities I got above (1/7 and 12/21), but I don't get far.

2. Dec 3, 2012

### Staff: Mentor

Not all possible pairs have the same probability. If you combine (6,1) and (1,6) to a single case, they have a higher probability than (4,4) (which just has one case).
There is a better (and more direct) way to get those probabilities. Do not combine cases. Once you have the probabilities for "sum 7" and "sum even", you can ignore all those individual cases.

1/7 and 12/21 are wrong.

Why do you expect this to work? What is P(2 sevens) after all? The probability to get 2 sevens in an infinite series?
This way, you would get 1/2 for all probability question. Even the question "how likely is it to have 100 times the sum 2 before getting the sum 7 once".

3. Dec 3, 2012

### D H

Staff Emeritus
That is the correct way to interpret the meaning of a "roll of a pair of fair die".

That is incorrect. You absolutely do need to distinguish (1,6) from (6,1). To make it a bit simpler, consider the outcomes from flipping a pair of coins, one a quarter, then other a nickel. There are four possible outcomes: Both coins come up heads, the quarter comes up heads while the nickel comes up tails, the quarter comes up tails while the nickel comes up heads, and both come up tails. These are equiprobable events.

Getting back to the problem of rolling the dice, look at rolling a sum of two versus rolling a sum of three. Both dice need to come up as one to roll a sum of two. The probability of this happening is 1/6*1/6, or 1/36. Now look at rolling a sum of three. It might help to imagine that the dice are colored, one red, the other green. You can roll a three by having the red die come up as one and the green die as two OR by having the red die come up as two and the green one as one. These are two independent events, each with probability 1/36, so the probability of rolling a sum of three with these colored dice is 2/36.

Now suppose you used two white dice. Does the color of the dice change the probabilities one bit?

4. Dec 3, 2012

### CAF123

No, the probabilities remain the same. So to get the sum =7, I use the joint prob;
P(sum =7) = P(X=1,Y=6) + P(X=2,Y=5) +... including one of the terms being P(X=6,Y=1), for example. Similarly to get sum=even. How should I compute P(2 sevens) and P(6 evens)?

5. Dec 3, 2012

### Ray Vickson

Each toss has three possible outcomes: O1 = '7', O2 = 'even', O3 ='other' (= odd but not 7). You have probabilities for each outcome on each toss, and the successive tosses are independent. So, you need to compute the probability of getting two O1's before 6 O2's.

One way to approach this is to ask what is the probability Pk that the game ends on toss k; that is, on toss k we have our second O1 and have fewer then 6 O2's. Can you see how to get that? Of course, you then need to sum over k.

6. Dec 3, 2012

### CAF123

So this is what I have. Assuming the game ends on round n, which means on the nth throw we have the second seven, out of the preceding n-1 throws we have to have one seven and less than 6 evens. So for the one seven we have (n-1 choose 1). P(seven).

I am not really sure how to compute P(less than 6 evens). I would say this is P(1 even) + P(2evens) +..+ P(5 evens), but I can't compute these individual terms

In the end, I want $$\sum_{n=1}^{∞} [\text{ (n-1 choose 1) . P(seven)}. \text{P(less than 6 evens)}]^{n-1} P(seven)$$

7. Dec 3, 2012

### Staff: Mentor

Here is a hint:
P(n-2 throws, 1 even)=P(1 throw, 1 even)*P(n-3 throws, 0 even)*(n-2 choose 1)
The last (n-2) corresponds to the number of ways to have that "1 even" in your series. n-2 is chosen because you need that in your formula ;).

8. Dec 3, 2012

### CAF123

Does this not assume that we want only 1 even in the n-2 throws?

9. Dec 3, 2012

### Ray Vickson

For n ≤ 6 it is fairly straightforward to calculate Pn (= probab. of a win on toss n) because in the first (n-1) tosses there cannot be 6 'evens'. Thus, if p_7 = Prob of a 7, p_e = prob of an 'even' and p_o = prob. of an 'other', Pn = p_7*Prob of 1 '7' in n-1 tosses. However, for n ≥ 7 it is a bit trickier: we must look only at those events in which there are ≤ 5 'evens' in (n-1) tosses. You can always do it the lengthy way: Pn = p_7*Q, where Q = P{ 1 seven and ≤ 5 evens in n-1 tosses} = Q0+Q1+Q2+Q3+Q4+Q5, where Qi = P{1 seven and i 'evens' in n-1 tosses}. Doing this by hand would be time-consuming, but it would not be too bad on a computer.

10. Dec 3, 2012

### CAF123

I haven't done anything with a computer as of yet, so I will have to do this by hand. Everything you wrote above makes sense, I am just finding it difficult to actually compute,s ay P(2 evens in n-1 tosses). I think this may be correct: $$\text{P(2 evens in n-1 tosses)} = \text{(n-1 choose 2)}.(1/2)^2(1-1/2)^{n-1-2}$$ and in general $$\text{P(i evens in n-1 tosses)} = \text{(n-1 choose i)}.(1/2)^i (1-1/2)^{n-1-i}$$

EDIT: SHould I replace n-1 by n-2 since we already have a 'slot' for the first seven?

Last edited: Dec 3, 2012
11. Dec 3, 2012

### Ray Vickson

Actually, you need things like P{2 evens and 1 seven in n-1 tosses}. This is easy enough once you have seen the "trinomial" distribution, but may be pretty hard otherwise. The trinomial (or, in general, the multinomial) is a generalization of the binomial distribution to handle more than two 'types' of outcomes. So, the probability of exactly 'a' sevens, 'b' evens and c = r-a-b 'others' in r tosses is
$${r \choose a,\, b,\, c}\: p_7^a \, p_e^b \, p_o^c \equiv \frac{r!}{a! \, b! \, c!} \:p_7^a \, p_e^b \, p_o^c \; (c = r - a - b).$$

The real problem with this approach is the need to do this for all n and to sum; a much easier approach would be to try to determine the following: let x(i,j) = probability of winning given there are i 7's and j evens up to now. You can develop a set of linear equations for the x(i,j) by looking at how you can after going from (i,j) to somewhere in 1 toss. You only need the x(i,j) for i = 0 and 1 and for j <= 5, for when you have these you can get P{win} = x(0,0).

For example, x(0,2) = p_7*x(1,2)+ p_o * x(0,2) + p_e*x(1,2) and x(1,3) = p_7 + p_o*x(1,3) + p_e*x(1,4), etc. The second of these equations is obtained by noting that to win from (1,3), we can either win directly (if we get 7), or else stay at (1,3) (if toss an 'other') or else must win from (1,4) (if we toss an 'even').

Last edited: Dec 3, 2012
12. Dec 4, 2012

### Staff: Mentor

Right, that is just one part of the calculation. I don't see a simple way to combine those cases.

13. Dec 4, 2012

### CAF123

Using the summation type approach, I have the following: $$\sum_{n=2}^{\infty} {n-1 \choose 1} \frac{1}{6} (1-\frac{1}{6})^{n-1-1} \sum_{i=0, n=3}^{n= \infty , i=5} {n-2 \choose i} (\frac{1}{2})^{i} (\frac{1}{2})^{n-2-i} ,$$ the reason for choosing the different values of n so that the binomial coefficients don't go to zero.

14. Dec 4, 2012

### Ray Vickson

If you use the recursive approach I suggested before, it leads you to a useful insight; after having that insight, you can dispense with the recursion (although is is still a useful method). Before, I introduced x(i,j) = Prob of winning, given i 7s and j evens already tossed, but it is easier to use instead y(i,j) = probability of winning, given i 7s and j evens left to go (that is, y(i,j) = x(2-i,6-j)). The case y(1,1) is easy: the game is over if 7 or an even is tossed, and it continues (from the same starting point) if 'other' is tossed. Thus, y(1,1) = p_7 + p_o y(1,1), so y(1,1) = p_7/(1 - p_o) = p_7/(p_7 + p_e). You can recognize this last quantity as P{7|7 or even}. That makes perfect sense when you think about it: the only 'relevant' outcomes are 7 or 'even', so the probability that the next 'relevant' outcome is a 7 is P{7|7 or even}.

So, if we let
p = P{&|7 or even} = p_7/(p_7 + p_e_)
and
q = P{even|7 or even} = p_e/(p_7 + p_e) = 1-p,
we have: y(1,1) = p.

Similarly, y(1,2) = p + p*q, y(1,3) = p+p*q + p*q^2, etc. These make perfect sense too, because when there are i 'evens' left to go we win if <= (i-1) 'evens' are obtained, followed by the winning '7'.

Our problem is like asking for 2 'heads' before 6 'tails' in coin tossing with a biased coin having P{H} = p and p{tail} = q. When we have just 1 H and i T's left to go, the probability we win (that is, get heads) is p*[1+q+q^2 + --- + q^(i-1)], because we can have <= i-1 tails followed by a head.

When we have 2 heads and i tails left to go, the first toss can be a head (leaving us with 1 head and i tails left to go) or it can be a tail, leaving us with 2 heads and (i-1) tails left to go. Thus, y(2,i) = p*y(1,i) + q*y(2,i-1). We already know all the y(1,i), so starting from y(2,1) = p^2 we can get y(2,2), y(2,3), y(2,4) and y(2,5). The answer to the original question is y(2,5).

15. Dec 4, 2012

### D H

Staff Emeritus
I think you meant y(2,6), not y(2,5). Initially there are 2 sevens, 6 evens to go to finish the game. y(2,6) agrees nicely with a Monte Carlo simulation.

Very, very nice analysis.

16. Dec 4, 2012

### CAF123

@RGV I am still in the process of understanding all that you wrote, but just to clarify: is what I wrote correct but difficult looking infinite sum, not correct but can be tweaked a little or somewhere incorrect? (thanks for those replies)

17. Dec 4, 2012

### haruspex

This is a classic random walk in two dimensions with two absorbing barriers.
Let (v,s) be the state of having v evens and s sevens so far, and vm=6, sm=2 be the absorbing boundaries.
For v<vm and s<sm, what are the transition probabilities to (v+1,s) and (v,s+1)?
How many paths are there to the point (s,v) where v<vm and s<sm?
So what is the probability of visiting (s,v) where v<vm and s<sm?
What are the possible prior states for (v,sm) where v<vm?
So what is the probability of being absorbed at (v,sm) where v<vm?

18. Dec 5, 2012

### Ray Vickson

There are infinitely many paths from (s,v) to the boundary, because the state (s,v) (and subsequent states) can be visited any number of times, due to the finite probability of 'no change' (when tossing an odd non-7). Of course, all we need to do is apply standard equations for absorption probabilities, and that is exactly what the 'recursive' approach I suggested is doing--but without mentioning using the word Markov, etc. By a bit of manipulation we can eliminate the 'self-loop' effects, and that is what my last posting was about.

19. Dec 5, 2012

### CAF123

Is this an approach using Markov chains? We covered part of this in an interest lecture at the end of our course. Just to check though: is my infinite sum correct that I had a few posts ago?

20. Dec 5, 2012

### haruspex

But we don't care how long we spend in a state, so you can elide those out. Having defined the states as I did, all we care about are the transitions. The probabilities are easily calculated.
I couldn't make sense of it. Are the ranges right on the double sum? Looks like it includes the combination n=3, i=5, which looks strange when you plug those numbers into the terms inside.

Last edited: Dec 5, 2012
21. Dec 5, 2012

### D H

Staff Emeritus
That's essentially what Ray did in post #14, which, if you read between the lines, spells things out very nicely.

I concur.

Last edited: Dec 5, 2012
22. Dec 5, 2012

### haruspex

Edited my post to remove. Would you mind editing yours to remove the quote?

23. Dec 5, 2012

### CAF123

@haruspex Sorry, I should probably try to explain. I assumed that n rolls were required to win. This means in the n-1 rolls, we must have one seven and less than 6 evens. The first sum I have deals with the 1 seven. Out of the n-1 rolls, we want 1 seven (that's where I get (n-1 choose 1). Then out of the n-2 rolls, we do not want a seven so that's the (1-1/6)^(n-2) part. Then we have the prob of actually getting this seven( which is the 1/6). Put this all together and sum to infinity (since there is no limit on the number of rolls) that's the first sum.

For the second sum, we want less than 6 evens. So consider each case separately (as mfb suggested too) that's why the sum goes from i=0 to i=5. Using similar reasoning to that above we arrive at the second sum. Perhaps the bit that's confusing you (and rightly so because it may not be correct) is the initial point for n. For the first sum, I have n from 2 to infinity, simply to not make the first binomial coefficient zero. Similarly for n=3 on the second sum so to make the (n-2 choose i) not trivially equal 0. Does it make sense?

This isn't actually a h/w problem, it is just self study. Thanks!

24. Dec 5, 2012

### haruspex

Ok, but you cannot then multiply this sum by something else to take into account that you must not have 6 evens. The correction factor would be a function of n, so it affects different terms in the first sum differently.
Please try my way. (It's pretty much the same as Ray's, but I was trying to lead you through it by getting you to answer a series of questions.) Did you understand how I defined the states and the transitions between them?

25. Dec 6, 2012

### CAF123

I would have happily tried your/Ray's approach, but I haven't covered that sort of material in my class yet (If it's Markov chains, then we only had one brief interest lecture on it at the end of the course. In that lecture we talked about weak/strong law of large numbers, Chebyshev's/Markov's inequality and some limit theorems) So I haven't really had that much practice using them.

Could you try to help me sort out my infinite sum? Or if that is looking too messy, then is there an alternate approach that is similar to mine (I.e something like failure on n-1, success on n) etc.

But thanks anyway for the alternative approaches - it is nice to know that there are other ways to solve these questions.