## Saturday, 26 January 2008

### Double Maths (again!)

Probability of throwing Any Yahtzee
last time we left off with the result of getting a specific Yhatzee was
p5 [1+q(1+q)]5 . Which I thought was a very neat (p=1/6, q=5/6). The next, and probably more realistic question is "what are the chances of throwing ANY Yahtzee". My first attempts were very much based on the previous attempts, and indeed I came up with a result of p4 [1+q(1+q)]4 . This However was wrong, this evaluates to 3.15%, when I did my test runs on it I came up with a value closer to 4.5%. My first thoughts were, the Java random algorithm was poor, but it did match the previous formulae for a specific Yahtzee, so I was wondering if my algorithm was wrong or I had a bug!!

After some further thought I realised that a potential for getting more Yahtzees was obvious.
• When you are going for a specific yahtzee and you have 0 1 or 2 matching numbers, you forge on...
• BUT if you need ANY old Yahtzee, then of you have 2 matching numbers, you are not tied to these. So lets say roll 1 gave you 2,2, 3,4,6 You hold the twos, roll again ... now there is a chance that you then roll a full house say 2,2,5,5,5. At this point you abandon yahtzees in 2's and go for the more fruitful 5's. And this is what my Yahtzee algorithm will do. Hence the extra Yahtzees.
My problem now was converting this into neat formulae as per my previous result. This was not so easy. So turning to google ... I found this ...http://www.yahtzee.org.uk/theory.html which was a different approach to me, but none the less had a very interesting set of results. The Yahtzee.ork.uk paper says getting any Yahtzee is about 3.7% (a bit low), and in general it dealt with the maths quite nicely, BUT, when dealing with 2-of-a-kind it did not consider abandoning it when a full house was thrown. When you start to look at the numbers throwing any two-of-a-kind (a pair and 3 other numbers or two pair and a single number) it is nearly 70% of the time... We are on the right track (thanks Yahtzee.org.uk)

So I perseveered. The eventual formula was derrived is a very similar way to previous with inspiration from the above paper. I'll not do all the maths but, here is a summary

5M (Yahtzee) --> 6/7776 == 6.p5
4M (4-of-a-kind) --> 150/7776 == 6.5.p4q
3M (3-of-a-kind) --> 1500/7776 == 6.10.10p3q2
2M(a pair) --> 5400/7776 == 6.Q.p2
0M(nothing) --> 720/7776 == 6.R.p

so p = 1/6, q=5/6, Q is a fudge and is 5400/1296 R is also a fudge and is 720/7776

1st Attempt
This is simple, roll a Yahtzee probability is
6.p5
• 5M --> 6.p5
or 0.077%

2nd Attempt
A few more combinations here
• 4M:5M --> 6.5.p4q . p
• 3M:5M --> 6.10.10p3q2 . p2
• 2M:5M --> 6.Qp2 .p3
• 0M:5M --> 6.p5
adding it up, after the 2nd attempt (so adding in the 1st attempt) we get

6p5(1 + 5q + 10q2 + Q + R), or 1.26%

3rd attempt

4 of a kind, 4 of a kind, then yahtzee ..
• 4M:4M:5M --> 6.5p4q . q . p
3 of a kind to 3 & 4 of a kind to Yahtzee
• 3M:4M:5M --> 10.6.p3q2 . 2pq . p
• 3M:3M:5M --> 10.6.p3q2 . q2 . p2

2 of a kind to 2,3,4 of a kind and then Yahtzee PLUS, 2 of one kind to 3 of another, to yahtzee

• 2M:4M:5M --> 6Qp2 . 3p2q . p
• 2M:3M:5M --> 6Qp2 . 3pq2 . p2
• 2M:2M:5M --> 6Qp2 . q3 . p3
• 2M:2N:5N --> 6Qp2 . 5p3 . p2

Nothing to something better to yahtzee (basically 6RP * 2nd attempt)

• 0M:0-4M:5M --> 6Rp . 6P5(5q + 10q2 + Q + R)
The whole lot

6p5{1+ (5q + 10q2 + Q + R)(1+6Rp) + 5q2 + 10q2[(1+q)2 – 1] + q[(1+q)3 -1] + 5Qp2}

Not so nice but is 4.610%, which is 3.47 times larger than a specific Yahtzee.

If anyone has suggestions for substitutions for P & Q (preferably to fit in with the binomial expansions) that make the above simpler feel free to comment..

Tally ho, I'm going to be running 10,000,000 games tonight.