none
Before revamping C# code, is this math correct? RRS feed

  • Question

  • Hey everyone,

    Sorry if this is in the wrong forum, but I didn't see any that was obvious to ask "pre coding" questions. Was trying to figure out some probability and statistics here, and was looking for people's input to see if my logic and math is correct or not before I set about trying to program it in our C# application.

    We have a program that randomly picks 6 non-repeating numbers from a selection of 35 in the range of 1 - 35.

    For example, 25,24,26,27,22,21 are valid results; 25,24,26,27,22,25 are not because the 25 repeats.

    1) We were wanting to know the probability of hitting those 6 numbers if we pick 8 random numbers from the group of 35.
    2) Similarly, we want to know the probability of hitting those 6 numbers if we pick 9 random numbers from the group of 35.

    Order is not important in the 8 or 9 random numbers we pick.
    That is, if our 6 numbers are: 25,24,26,27,22,21
    We can pick 2,4,25,5,24,7,21,22 and 4 of the numbers would be considered a match (25,24,22,21).

    3) We also want to know the probability of hitting those 6 numbers if we pick 8 random numbers 8 times.
    4) We also want to know the probability of hitting those 6 numbers if we pick 8 random numbers 10 times.
     

    Here's the Math I currently have. Is this correct?

    There are 33,891,580,800 possible ways to pick 6 of 35 numbers.

    35*34*33*32*31*30*29 = 33,891,580,800

    There are 40320 distinct combinations of any 8 numbers:

    8*7*6*5*4*3*2*1 = 40320

    Since order is not important, we multiply this by 8 to get 322560.

    There are 362,880 distinct combinations of any 9 numbers:

    9*8*7*6*5*4*3*2*1 = 362,880

    So my answers to the above questions are:

    1) 33,891,580,800 / 322,560
    2) 33,891,580,800 / 362,880
    3) 33,891,580,800 / (322,560 * 8) = 33,891,580,800 / 2,580,480
    4) 33,891,580,800 / (322,560 * 10) = 33,891,580,800 / 3,225,600

    Is this math right? Wrong?

    Thanks!

     

    Friday, January 7, 2011 1:25 AM

Answers

  • What you're counting is the number of permutations (ordered sequences) of 7 (not 6) values among 35.

    If the order is not significant, you need the number of combinations: n!/k!(n-k)!

    (35*34*33*32*31*30)/(6*5*4*3*2*1) = 1623160

    But that number is not significant.

    What is significant is the number of combinations of 8 containing those 6 winning numbers: 29*28/2 = 406.

    There are (35*34*33*32*31*30*29*28)/(8*7*6*5*4*3*2*1) = 23535820 combinations of 8 numbers.

    The probability of picking one of the 406 sets is 406 / 23535820 = 0.00001725

    Friday, January 7, 2011 9:06 AM

All replies


  • Do you want to get the probability of hitting all 6 numbers if you pick 8, or do you want the probability of hitting any of the six numbers while picking 8?

    --
    Mike
    Friday, January 7, 2011 2:41 AM
  • Mike,

    Good question. For clarification, would want the math to figure out the probability of hitting 4 of the 6 numbers, 5 of the 6 numbers, and all 6 numbers.

    Thanks!

    Friday, January 7, 2011 3:02 AM
  • Something just does not seem right with the way you got the distinct combinations of 8 (or 9) numbers, since the 36 does not play a part in it, but maybe it's just too late here.  Sorry I cannot solve it tonight.  Maybe someone else in a better time zone will.
     

    --
    Mike
    Friday, January 7, 2011 3:59 AM
  • What you're counting is the number of permutations (ordered sequences) of 7 (not 6) values among 35.

    If the order is not significant, you need the number of combinations: n!/k!(n-k)!

    (35*34*33*32*31*30)/(6*5*4*3*2*1) = 1623160

    But that number is not significant.

    What is significant is the number of combinations of 8 containing those 6 winning numbers: 29*28/2 = 406.

    There are (35*34*33*32*31*30*29*28)/(8*7*6*5*4*3*2*1) = 23535820 combinations of 8 numbers.

    The probability of picking one of the 406 sets is 406 / 23535820 = 0.00001725

    Friday, January 7, 2011 9:06 AM