Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

If you have two bags each containing 100 numbered balls and pick 1 ball at random from each bag, what are the odds that you will pick two similarly numbered balls?

I believe this is equivalent to the Birthday paradox equation:

T! 1 - ----------------- T^n . ( T - n )!

Which for T=100, n=2 comes out to:

use strict; use bignum; sub fact{ my($r,$n) = (1,shift); $r *= $n-- while $n; return $r; } print 1-((fact(100)/fact(98))/100**2);

gives 0.01 or 1% chance.

My question is, if I have 2 pairs of 2 bags and pick one ball from each, what are the odds of the first pair being identical to the second pair?

For my purposes, order does matter. So, the question is really what are the odds that ball 1 from each of pair1/bag1 & pair2/bag1 will be identical; and ball 2 from each of pair1/bag2 & pair2/bag2 will also be identical?

Is this a simple combination of odds? Eg. 0.01 * 0.01 == 0.0001?

Replies are listed 'Best First'.
Re: Math help
by Melly (Chaplain) on Nov 27, 2006 at 11:03 UTC

    Not quite, IMHO.

    Consider 2 bags with only 2 balls in each:

    Ball 1 the same: 50%
    Ball 2 the same (assuming ball 1 was the same): 100%

    So, you have to take into account the reduced number of balls on the second pick:

    Ball 1: 1/100 = 1%
    Ball 2: 1/99 = 1.01%
    Total odds: 0.0101%

    Tom Melly, tom@tomandlu.co.uk

      Thanks, but in my question there are 2 pairs of two bags (4 bags) and only 1 ball is drawn from any given bag, so the choice is always 1:100.

      The question is really, as these are unconnected events, is a simple product of the single bag probabilities correct?

        hi,

        If you don't care if the balls from the first pair are equal or not, you just want that pair1/bag1=pair2/bag1 and pair1/bag2=pair2/bag2, your answer is correct. The odds are 0.0001 (0.01%).

        But if you want that pair1/bag1=pair1/bag2 and pair1/bag1=pair2/bag1 and pair1/bag2=pair2/bag2, then you will need to multiply another time, and the correct answer will be 0.000001 (0.0001%).

Re: Math help
by Not_a_Number (Prior) on Nov 27, 2006 at 17:49 UTC

    <disclaimer> IMNAM (I Am Not A Mathematician), but this is my understanding the problem (OT, by the way:). Maybe some maths guru will come along and prove me wrong.</disclaimer>

    You draw your first two balls. These are either (a) different or (b) identical.

    (a) If they are different (say 23 and 59), your odds of drawing one of these numbers of of the third bag are 2/100, or 1/50, or 0.02. Say you draw the 23. You must then draw the 59 from the fourth bag, for which your odds are obviously 1/100, or 0.01. So if (a) is true, your total odds are 0.01 * 0.02 = 0.0002 (or 1/5000).

    (b) However, there is a possibility (1/100, or 0.01) that your first two balls will be identical. In that case, you have only a 1/100 chance of drawing a third identical ball, and if you should succeed there, you would again have a 1/100 chance of drawing a fourth identical ball. So if (b) is true, your total odds are 0.01 * 0.01 = 0.0001 (or 1/10000).

    Now, the chances of (b) being true are 0.01 (1/100), while the chances of (a) being true are 0.99 (99/100). So your total odds are:

    0.01 * 0.0001 + 0.99 * 0.0002 = 0.00000001 + 0.000198 = 0.00019801

    Update: Changed order of (a) and (b) in second paragraph to match the rest of the text.