Results 1 to 3 of 3

Math Help - Random Within Random Probabilities

  1. #1
    Newbie DarthRiko's Avatar
    Joined
    Apr 2010
    Posts
    2

    Random Within Random Probabilities

    I fancy myself a programmer, and I've created a bit of code including a randint(randint(1,6),6). For those of you who don't speak the same language I do, it basically finds a random integer from 1 to 6, and then finds a random integer from that number and 6 again.
    Once I got done with the bit I was using it for, I got curious as to the probabilities of it returning certain numbers.
    I tried doing some simple math in my head, but my brain kept throwing in the fact that there is no such thing as true randomness in programming, and my math kept getting super complicated, and ultimately wrong. So I googled for a math help forum and came here.
    Can anyone tell be the probabilities of my formula returning each number from 1 to 6?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    Opalg's Avatar
    Joined
    Aug 2007
    From
    Leeds, UK
    Posts
    4,041
    Thanks
    7
    Quote Originally Posted by DarthRiko View Post
    I fancy myself a programmer, and I've created a bit of code including a randint(randint(1,6),6). For those of you who don't speak the same language I do, it basically finds a random integer from 1 to 6, and then finds a random integer from that number and 6 again.
    Once I got done with the bit I was using it for, I got curious as to the probabilities of it returning certain numbers.
    I tried doing some simple math in my head, but my brain kept throwing in the fact that there is no such thing as true randomness in programming, and my math kept getting super complicated, and ultimately wrong. So I googled for a math help forum and came here.
    Can anyone tell be the probabilities of my formula returning each number from 1 to 6?
    The first randint(1,6) returns each of the numbers 1,2,...,6 with a probability of 1/6. The only way that the second randint can return a 1 is if the first randint is a 1 (probability 1/6) and so is the second (probability again 1/6. These probabilities have to be multiplied, so the probability of the combined process returning a 1 is 1/36\approx 0.028.

    To get a 2 from the combined process, you either need a 1 first time (prob. 1/6) and then a 2 (prob. again 1/6); or you get a 2 first time (prob. 1/6) and then another 2 (prob. 1/5 this time, because there are only the five numbers 2,3,...,6 to choose from). So the probability of the combined process returning a 2 is \tfrac16\bigl(\tfrac16+\tfrac15\bigr)\approx 0.061.

    Continuing in that way, the probability for each of the remaining numbers being returned by the combined process is:

    prob. that it is 3 is \tfrac16\bigl(\tfrac16+\tfrac15+\tfrac14\bigr)\app  rox 0.103,
    prob. that it is 4 is \tfrac16\bigl(\tfrac16+\tfrac15+\tfrac14 +\tfrac13\bigr)\approx 0.158,
    prob. that it is 5 is \tfrac16\bigl(\tfrac16+\tfrac15+\tfrac14+\tfrac13+  \tfrac12\bigr)\approx 0.242,
    prob. that it is 6 is \tfrac16\bigl(\tfrac16+\tfrac15+\tfrac14+\tfrac13+  \tfrac12+1\bigr)\approx 0.408.

    As a check, you can add the six probabilities and see that their sum comes to 1.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie DarthRiko's Avatar
    Joined
    Apr 2010
    Posts
    2
    I'm not very good with writing thank yous, so my gratitude won't be fully expressed. Still, thanks.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Probability and random random varible question
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: May 15th 2010, 08:53 PM
  2. exponential random variable with a random mean?
    Posted in the Advanced Statistics Forum
    Replies: 2
    Last Post: March 21st 2010, 02:05 PM
  3. Replies: 9
    Last Post: January 28th 2010, 07:26 AM
  4. Replies: 3
    Last Post: January 13th 2010, 10:44 AM
  5. Random vectors & random matrices (1)
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: June 15th 2009, 11:18 PM

Search Tags


/mathhelpforum @mathhelpforum