Subscribe via feed.

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?

This post is under “Tom” and has 6 respond so far.
If you enjoy this article, make sure you subscribe to my RSS Feed.

6 Responds so far- Add one»

  1. 1. Chris Said:

    See the previous problem for some background. We have three types of face. I’ll use subscripts to denote those types. I’ll use ni to denote the number of type i faces yet to be seen, and pi 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[n1,n2,n3] be the total average number of rolls. Then
    n[n1,n2,n3]= 1 + p1n1n[n1-1,n2,n3] + p2n2n[n1,n2-1,n3] + p3n3n[n1,n2,n3-1] + (1-p1n1-p2n2-p3n3)n[n1,n2,n3]
    Solving for n[n1,n2,n3] => n[n1,n2,n3] =

    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.]

  2. 2. knightmare Said:

    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

  3. 3. ragknot Said:

    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.

  4. 4. ragknot Said:

    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.

  5. 5. Chris Said:

    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[n1,n2,n3]= 1 + p1n1n[n1-1,n2,n3] + p2n2n[n1,n2-1,n3] + p3n3n[n1,n2,n3-1] + (1-p1n1-p2n2-p3n3)n[n1,n2,n3] is interpreted as, we do one roll (hence the 1), then we have a probability p1n1 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[n1-1,n2,n3]. 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-p1n1-p2n2-p3n3, then we still have n[n1,n2,n3] rolls to go.

    Next I simply rearranged the equation (i.e. I solved it for n[n1,n2,n3]). Then I proceeded to evaluate all the values of n[n1,n2,n3], starting from the obvious case of n[0,0,0] = 0. e.g. n[1,0,0] = (1 + 1*p1*n[0,0,0] + 0 + 0) / (1*p1 + 0 + 0) => n[1,0,0] = 1/p1. You can then continue in this fashion to find all the n[n1,0,0] values. You can then do the same for n[0,1,0] etc., etc.

    Although I defined n[n1,n2,n3] 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.

  6. 6. Chris Said:

    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.

Post a reply

PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP5\ext\php_mssql.dll' - The specified module could not be found. in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP5\ext\php_pdo_mssql.dll' - The specified module could not be found. in Unknown on line 0