## Strange Die #2

Posted by ragknot on October 4, 2011 – 3:08 pm

The other die of the Strange Dice pair is different.

Half the time you roll a one, it appears as a two. The normal side two always appears as a two. What is the average number of rolls of the die to get each number (1 to 6) at least once?

October 4th, 2011 at 6:51 pm

See the previous problem for some background. We have three types of face. I’ll use subscripts to denote those types. I’ll use n

_{i}to denote the number of type i faces yet to be seen, and p_{i}to denote the probability of seeing a particular type i face. I’ll specialise to i = 1,2,3, but recognise that this can be extended indefinitely.Let n[n

_{1},n_{2},n_{3}] be the total average number of rolls. Thenn[n

_{1},n_{2},n_{3}]= 1 + p_{1}n_{1}n[n_{1}-1,n_{2},n_{3}] + p_{2}n_{2}n[n_{1},n_{2}-1,n_{3}] + p_{3}n_{3}n[n_{1},n_{2},n_{3}-1] + (1-p_{1}n_{1}-p_{2}n_{2}-p_{3}n_{3})n[n_{1},n_{2},n_{3}]Solving for n[n

_{1},n_{2},n_{3}] => n[n_{1},n_{2},n_{3}] =(1+p

_{1}n_{1}n[n_{1}-1,n_{2},n_{3}]+p_{2}n_{2}n[n_{1},n_{2}-1,n_{3}]+p_{3}n_{3}n[n_{1},n_{2},n_{3}-1])/(p_{1}n_{1}+p_{2}n_{2}+p_{3}n_{3})For the posed problem, we have one type 1 face (namely face 1) with a probability of 1/12, one type 2 face with a probability of 3/12, and four type 3 faces with a probability of 1/6 (each).

I tweaked the code that I posted into the last problem and out popped

n(1,1,4) = 17.6194805194805

As I think I can see the repetition in that number, I can deduce the exact value. We have 17 + 6/10 + 194805/9999990

= (17*9999990 + 6*999999 + 194805)/9999990 = 13567/770

[I have now confirmed that exact value with Mathematica.]

October 4th, 2011 at 9:22 pm

what the hell is this!!! this new site doesn’t show how many respones there are , who posted it, or gives us a clue which are the author’s comments!

are we losing ToM??

i’m sad

October 4th, 2011 at 10:15 pm

It says 2 posts, and you were number 2 Knightmare.

I got the read Chris’s #1 post, It looks like I could learn how Chris does it.

October 4th, 2011 at 10:26 pm

I got 17.6198… But I can’t verify that much accuracy.

Chris says … 17.6194805194805, which has be right.

I considered to now play “craps” with my strange dice. But they would kick me out when a rolled a seven with one die.

Thanks for revealing how that works, Chris. It will take more reviewing for me to learn how that works.

October 5th, 2011 at 4:21 am

The site layout had gone nuts for a day. It seems to be back to normal

As ragknot hadn’t noticed it, I guess it must have ben related to Internet Explorer.

I’ll try to explain the method. The initial equation

n[n

_{1},n_{2},n_{3}]= 1 + p_{1}n_{1}n[n_{1}-1,n_{2},n_{3}] + p_{2}n_{2}n[n_{1},n_{2}-1,n_{3}] + p_{3}n_{3}n[n_{1},n_{2},n_{3}-1] + (1-p_{1}n_{1}-p_{2}n_{2}-p_{3}n_{3})n[n_{1},n_{2},n_{3}] is interpreted as, we do one roll (hence the 1), then we have a probability p_{1}n_{1}that we’ll roll a type 1 face that we haven’t already rolled, etc. If we happen to roll a type 1 face, then we have one less type 1 face to be seen, so the new number of rolls to go is (by definition), n[n_{1}-1,n_{2},n_{3}]. Similarly for type 2 and 3 faces. The last bit of the equation says that, if we roll a face that we’ve already seen, the probability of which is 1-p_{1}n_{1}-p_{2}n_{2}-p_{3}n_{3}, then we still have n[n_{1},n_{2},n_{3}] rolls to go.Next I simply rearranged the equation (i.e. I solved it for n[n

_{1},n_{2},n_{3}]). Then I proceeded to evaluate all the values of n[n_{1},n_{2},n_{3}], starting from the obvious case of n[0,0,0] = 0. e.g. n[1,0,0] = (1 + 1*p_{1}*n[0,0,0] + 0 + 0) / (1*p_{1}+ 0 + 0) => n[1,0,0] = 1/p_{1}. You can then continue in this fashion to find all the n[n_{1},0,0] values. You can then do the same for n[0,1,0] etc., etc.Although I defined n[n

_{1},n_{2},n_{3}] as a function, the arguments are integers, and so it is natural to treat it as an array, then coding is a doddle.Here’s my (quick and dirty) code. I’ve used a lower array bound of -1 to avoid VB errors, due to VB not understanding that 0 * undefined = 0.

Sub Strange()

Const n1i = 1

Const n2i = 1

Const n3i = 4

Dim n1, n2, n3 As Integer

Dim p1, p2, p3 As Double

Dim n(-1 To n1i, -1 To n2i, -1 To n3i) As Double

p1 = 1 / 12

p2 = 3 / 12

p3 = 2 / 12

n(0, 0, 0) = 0#

For n3 = 0 To n3i

For n2 = 0 To n2i

For n1 = 0 To n1i

If n1 + n2 + n3 > 0 Then

n(n1, n2, n3) = (1 + p1 * n1 * n(n1 – 1, n2, n3) + p2 * n2 * n(n1, n2 – 1, n3) + p3 * n3 * n(n1, n2, n3 – 1)) / (p1 * n1 + p2 * n2 + p3 * n3)

End If

Next n1

Next n2

Next n3

Debug.Print n(n1i, n2i, n3i)

End Sub

It wouldn’t take a huge effort to generalise it to work with any number of types of face.

October 5th, 2011 at 7:37 pm

PS Thank you for the problem ragkot. I quite enjoyed deriving the relatively general equation.

My VB is a little rusty, so I’m not sure how difficult it would be to generalise for a variable number of types. It could be done in a decent language such as C or C++, but it would be a bit fiddly to do.